Hi,
No need of QITemDelegate to display a checkbox.
(this is extracted from an implementation of QAbstractItemModel)
@Override
public ItemFlags flags(QModelIndex index) {
return new ItemFlags(new ItemFlag[] {
ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled,
ItemFlag.ItemIsUserCheckable });
}
than in setData() and data(), you need to handle the CheckStateRole.
For example :
@Override
public boolean setData(QModelIndex index, Object value, int role) {
if (role == ItemDataRole.CheckStateRole) {
...
return true;
}
return super.setData(index, value, role);
}
@Override
public Object data(QModelIndex index, int role) {
...
switch (role) {
case ItemDataRole.CheckStateRole:
...
}
return null;
}
2009/6/19 Manuel <[email protected]>
>
> Hi,
>
> i have some general questions about QTableView, QAbstractTableModel and
> QItemDelegate.
>
> For example i have a Model that contains a Vector of Data, which should
> be displayed by the View.
>
> Ich changed the data()-method of my Model, so that it will return a
> QCheckBox, but the Checkbox will never be displayed. I think i need to
> implement the Display of the CheckBox in the paint-method of the
> QItemDelegate. Is that correct? Do i really need to implement it by
> myself or is there already an implementation to do that?
>
> Best regards,
> Manuel
> _______________________________________________
> Qt-jambi-interest mailing list
> [email protected]
> http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest