PyQt: Problem finding and showing a record in a QDataBrowser

J

Jorge Godoy

[I've also posted this to pyqt-pykde list, but I haven't got any answers so
far. I also thought that someone here might have solved it or have a
different idea to help me :) Sorry for those that read it twice. ]


Hi.


I have created an interface where I have a QDataBrowser and all of its
editing and navigating controls and one of the displayed controls is in a
QSpinBox.

I have the navigation from current to next and previous records working fine
if I only use the data browser controls. I also can recover the correct
record if I type in a valid code at the spin box.

For the spin box to work, I'm doing this:


def codAmostra_valueChanged(self, amostra_id):
cursor = self.dbAmostras.sqlCursor()
cursor.select('amostra_id=%s' % amostra_id)
self.dbAmostras.first()
self.dbAmostras.refresh()


(codAmostra is my spinbox, dbAmostras is my QDataBrowser -- just as a
curiosity, "amostra" is the pt_BR for "sample")

I was willing to use "self.dbAmostras.seek()", but it requires that I know
the exact position of the record -- using it I wouldn't need to filter my
data and I think the problem would be solved... -- but I don't know it.

There can be "holes" in my sequence (otherwise I'd use only the spinbox) and
I'll be having a few million entries (what makes it impossible to go
through each and every record every time I change the value at the spinbox
manually).

I was reading Qt3 docs trying to find out some other mean to recover the
record I need without messing with the filter because if I use the filter,
then I can't paginate through all records anymore.

Any hints on an alternative approach that would allow me to use both
controls?


* Python 2.4
* SIP 4.1.1 (4.1.1-255)
* >>> qt.qVersion()
'3.3.4'

Thanks in advance,
 
J

Jorge Godoy

Jorge said:
I have created an interface where I have a QDataBrowser and all of its
editing and navigating controls and one of the displayed controls is in a
QSpinBox.

I have the navigation from current to next and previous records working
fine if I only use the data browser controls. I also can recover the
correct record if I type in a valid code at the spin box.

Just to make the answer available to other that might have the same problem,
I had to deactivate the framework code and handle the cursor from the
databrowser manually.

It also fixed a performance problem since I only have one record fetched and
not all of them. This makes the answer time linear (database dependant, of
course) no matter how many records I have on the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top