vieraci
29th May 2009, 17:53
I have a table of data with a combo box delegate on one of the columns. I have a problem in creating the delegate efficiently.
The table data is a joined query so I can have the column I want to edit showing the text it relates to instead of the integer code in the table.
I can't use a QSqlRelational* object because the related table data is a subset from a table without a useable index and a some WHERE clauses to filter out unrelated rows. My solution is to load the combo box with a query.
It works, but the combo box is created in the createEditor method, which means every time the field is being edited the query has to be executed. The sensible thing to do here is have the combo box created in the ctr and loaded once...right ?
My problem is I can't work out how to create the combo box in the ctr. QComboBox requires a QWidget as it's parent (which is supplied via createEditor(QWidget *parent... but the ctr code has a QObject parameter as a parent and the code doesn't compile. This is probably a simple answer but I can't think what it may be. Can anyone help please ?
The table data is a joined query so I can have the column I want to edit showing the text it relates to instead of the integer code in the table.
I can't use a QSqlRelational* object because the related table data is a subset from a table without a useable index and a some WHERE clauses to filter out unrelated rows. My solution is to load the combo box with a query.
It works, but the combo box is created in the createEditor method, which means every time the field is being edited the query has to be executed. The sensible thing to do here is have the combo box created in the ctr and loaded once...right ?
My problem is I can't work out how to create the combo box in the ctr. QComboBox requires a QWidget as it's parent (which is supplied via createEditor(QWidget *parent... but the ctr code has a QObject parameter as a parent and the code doesn't compile. This is probably a simple answer but I can't think what it may be. Can anyone help please ?