PDA

View Full Version : QComboBox setMaxVisibleItems, need help?



johnibat
8th December 2010, 22:59
Hi everyone how to user setMaxVisibleItems() with QCombobox?

thank you very much.

tbscope
9th December 2010, 05:21
http://doc.qt.nokia.com/4.7/qcombobox.html#maxVisibleItems-prop

Is there something specific you want help with?

johnibat
9th December 2010, 11:21
Why this code don't work?



int numItems = 300;
QStandardItemModel * queryModel = new QStandardItemModel(numItems , 1);

for (int row=0; row<numItems; ++row) {
QStandardItem *item = new QStandardItem(QString("row %0").arg(row));
queryModel->setItem(row, 0, item);
}
QComboBox *combo = new QComboBox;
combo->setModel(queryModel);
combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// MaxVisibleItems set
combo->setMaxVisibleItems(20);//why this don't work
combo->show();



thanks

tbscope
9th December 2010, 15:57
Does the following apply to your system?


This property is ignored for non-editable comboboxes in styles that returns false for QStyle::SH_ComboBox_Popup