[PyQt] Adapting a QTableWidget to display an arbitrary QSqlQuery result set

Bernard Van Der Stichele Bernard_VanDerStichele at otpp.com
Fri Sep 4 19:54:29 BST 2009

Hi All,

I'm just starting out with PyQt.
I have a simple app which allows the user to enter & execute select 
queries against any arbitrary table/s in a database. I want to display the 
results in a sortable grid, such as a QTableWidget.
The question is how do I go about re-sizing the table based on the number 
of columns in the result set (since the number of columns will vary)? I 
was hoping to be able to obtain the count of values (i.e. fields) in each 
query record, but it isn't available. 

Alternatively is there a way to 'bind' a query to a QTableWidget?


This e-mail message, including any attachment(s), is confidential. If we sent this communication to you in error, please do not disclose it to anyone else or use the information in it. Please notify the sender of the transmission error and then delete our communication from your system without printing, copying or forwarding it.  Thank you for your co-operation.


Le present courriel, y compris toute piece qui y est jointe, est confidentiel. Si nous vous avons envoye cette communication par erreur, nous vous prions de ne la divulguer a personne ni a utiliser l’information qu’elle contient. Veuillez informer l’expediteur de l’erreur de transmission et effacer ensuite notre communication de votre systeme sans l’imprimer, ni la copier ni la retransmettre. Nous vous remercions de votre cooperation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090904/5dbb590f/attachment.html

More information about the PyQt mailing list