wysman
20th May 2009, 14:28
Hello,
In my project, i need to populate a ListView with different item. Those items can have différent nature, and need a custom widget for drawing and editing.
I have build a custom widget (Widget_CarteFille_Gpio) with QDesigner (1 layout, 2 label, 2 combo-box)
Widget_CarteFille_Gpio::Widget_CarteFille_Gpio (QWidget *parent) :
QWidget (parent)
{
setupUi (this);
}
Next, i try to subclass a QItemDelegate who build my new widget for the editing.
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Widget_CarteFille_Gpio *editor = new Widget_CarteFille_Gpio (parent);
return editor;
}
I build the project, and exec the application !
When I double click on the item my widget is not show !
I read this exemple : http://doc.qtsoftware.com/4.5/itemviews-stardelegate.html but they draw directly on a widget, this is little different of my problem.
If someone have a code exemple about draw a custom widget for viewing/editing in a ListView. I was very interresting.
Thanks
Apologize for my English !
In my project, i need to populate a ListView with different item. Those items can have différent nature, and need a custom widget for drawing and editing.
I have build a custom widget (Widget_CarteFille_Gpio) with QDesigner (1 layout, 2 label, 2 combo-box)
Widget_CarteFille_Gpio::Widget_CarteFille_Gpio (QWidget *parent) :
QWidget (parent)
{
setupUi (this);
}
Next, i try to subclass a QItemDelegate who build my new widget for the editing.
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Widget_CarteFille_Gpio *editor = new Widget_CarteFille_Gpio (parent);
return editor;
}
I build the project, and exec the application !
When I double click on the item my widget is not show !
I read this exemple : http://doc.qtsoftware.com/4.5/itemviews-stardelegate.html but they draw directly on a widget, this is little different of my problem.
If someone have a code exemple about draw a custom widget for viewing/editing in a ListView. I was very interresting.
Thanks
Apologize for my English !