PDA

View Full Version : QComboBox strange behavior



Antebios
29th January 2009, 20:07
I'm using 4.4.3, so I'm trying to create a proof-of-concept page and playing with display widgets. I have a table with 2 columns (ID, Description) and want to store the ID in a Data Value field and Description in a Text Value field, and ID field invisible and Description field visible. I know how to do this in .Net C#, but how do I do this in Qt?

This is what I've done:

QComboBox *cmbBox = Concept::ui.cmbItems;
QSqlQueryModel *_model = new QSqlQueryModel;
_model->setQuery("select lookupid, lookupdescr from tblLookup");
cmbBox->clear();
cmbBox->setModel(_model);


But, only the ID field is shown, so I used:

cmbBox->setModelColumn(1);
but either the primary key shows up, and the rest of the Description text, or only the first item and the second item is not visible.

I've been searching for help, but the documentation doesn't tell me how to do this. I want to get the ID from the selected item, but not show it.

wysota
29th January 2009, 21:38
but either the primary key shows up, and the rest of the Description text, or only the first item and the second item is not visible.

What does this mean? The solution using setModelColumn() should have worked correctly - you should have gotten a combobox with values from the second column of your model.

Antebios
31st March 2009, 23:50
The latest Qt 4.5.0 solved this problem/bug.