[Qt-interest] realize a widget like QComboBox but with QCheckBox as its items

Alessandro Vanzulli alessandro.vanzulli at gmail.com
Wed Mar 18 22:00:32 CET 2009


Hi,
the createEdit method of delegate is called from the view class when the
user request the Edit funcion of a specific item.For example, I have a
QTableVIew and the createEditor is called only when the operator perform a
double click on one of the displayed cells.

In your case, it is normal that the createEdit delegate is not called. I
hope that you have to reimplement the paint method or something similar for
display the checkbox on every item of ComboBox.

Bye

Alessandro


2009/3/18 吴海峰 <wuhf at nari-relays.com>

>  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!
>
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090318/b130fc53/attachment.html 


More information about the Qt-interest-old mailing list