Changing data in an QAbstractListModel

exhuma.twn exhuma at gmail.com
Fri Sep 7 04:24:40 EDT 2007


On Sep 7, 12:42 am, Jonathan Gardner
<jgardner.jonathangardner.... at gmail.com> wrote:
> On Sep 6, 9:12 am, "exhuma.twn" <exh... at gmail.com> wrote:
>
> > I defined a simple "update" method in the model which I call on
> > certain events to fetch the new data in the DB. I tried to "emit" the
> > "dataChanged()" signal of the Model without success. I don't know
> > where I should get the two required "index" parameters from.
>
> > Any hints?
>
> Shouldn't the index method give you the indexes you need?

Right... The update method now looks like this:

   def update(self):
      c = db_con.cursor()
      # SELECT only the most recent entry for each company
      c.execute("SELECT DISTINCT ON (unit_id) nom FROM unit ORDER BY
unit_id, year DESC")
      for unit in c.fetchall():
         self.__units.append( unit[0] )
      c.close()

      si = self.index(0)
      se = self.index(len(self.__units)-1)

      self.emit(Signal("dataChanged()"), si, se)


Still, nothing is happening when I call this method. Do I still need
to handle the "dataChanged" signal somehow? Or does the ListView take
care of this?




More information about the Python-list mailing list