I want to show a QComboBox within specific cells of a QTreeView. I know I have to use an own model for it. The whole thing is already working properly with QIcons shown in the cell, but I fail doing the same with a combobox. That's what my model looks like (some incomplete pseudo-code):
QVariant MyListModel::data(const QModelIndex &index, int role) const
{
...
switch(role)
{
...
case Qt::DecorationRole:
switch(index.column())
{
case eBLA:
// return QIcon(); --> compiles properly
return m_placePosCombos[index.row()]; --> compilation fails
return QComboBox(); --> compilation fails
break;
default:
As soon as I try to return a QComboBox, I get a compilation error
cannot convert from 'const QComboBox' to 'QVariant'
MyListModel inherits from QAbstractListModel.
Any idea what I have to do to use a QComboBox instead of a stupid icon?
Thanks!
No, model is only for data handle in a view, and not for change the view. You need to learn and use: QItemDelegate (sorry for not show you here all the code, it needs place and time for that... the time you may have to read tuto and relative doc... hope that help)