[PyQt] Adapting a QTableWidget to display an arbitrary QSqlQuery
result set
David Boddie
david at boddie.org.uk
Sat Sep 5 00:05:12 BST 2009
On Fri Sep 4 19:54:29 BST 2009, Bernard Van Der Stichele wrote:
> 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.
I'm not really familiar with SQL, but I don't think this is necessary if
you are using Qt's model/view framework to display the results of queries.
> Alternatively is there a way to 'bind' a query to a QTableWidget?
Have you seen the querymodel.py example supplied with PyQt4?
David
More information about the PyQt
mailing list