[Qt-interest] realize a widget like QComboBox but with QCheckBox as its items
吴海峰
wuhf at nari-relays.com
Wed Mar 18 13:49:00 CET 2009
Hello everybody,
I want to realize such a widget which it is just like a QComboBox in the whole but with QCheckBox as its items, instead of text strings.
I have searched the list but without luck.
I use MVD. The Following is my code:
QComboBox *editor = new QComboBox(parent);
// list is used to store data.
CItemModelForComboBox * pModel = new CItemModelForComboBox(list.count(), 1); // CItemModelForComboBox subclass QStandardItemModel
for(int i=0; i<list.count(); i++)
{
pModel->BuildDataIntoModel(QString("%1").arg(list[i].m_nValue), list[i].m_strValue);
}
QListView *pShowWidget = new QListView;
pShowWidget->setModel(pModel);
editor->setModel(pModel);
CItemDalegateForComboBox * pDelegate = new CItemDalegateForComboBox(); // CItemDalegateForComboBox subclass QItemDelegate
pShowWidget->setItemDelegate(pDelegate);
editor->setView(pShowWidget);
return editor;
During the debug, I was told that CItemDalegateForComboBox functions such as "createEditor" never entered.
Can anyone give me some hints to solve it? Many Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090318/912df95b/attachment.html
More information about the Qt-interest-old
mailing list