PDA

View Full Version : qcombobox with multiple columns



seniorc
25th May 2014, 17:48
Hello,

I'm trying show QTableView in QComboBox.

Example Department is table in my database.

Query =


SELECT Dep.Code,Dep.Name FROM Dep

and I've tried this my code.


QSqlQueryModel* depModel = new QSqlQueryModel();
depModel->setQuery("SELECT Dep.Code,Dep.Name FROM Dep");
.
.
.
QTableView* cboxTable = new QTableView(this);
cboxTable->setModel(depModel);
QComboBox *courseComboBox = new QComboBox();
courseComboBox->setView(cboxTable);

but not work.Where is my problem ? I want see multiple columns.

Here is this problem stackoverflow link (http://stackoverflow.com/questions/23849874/qt-qcombobox-with-multiple-columns?noredirect=1#comment36704087_23849874)

ChrisW67
25th May 2014, 21:37
What "does not work" about it? You see no data, no drop down, no columns, only one column, the wrong value when selected, pink MS Comic Sans text? Where do you set the model on the combo box?