Skip to content
QtWS25 Last Chance
  • 2 Votes
    7 Posts
    3k Views
    H
    For the record, this was a perfectly good question. The QAbstractItemModel::createIndex() docs do not state that it embeds a model pointer into the index it creates, nor do the QModelIndex docs mention the private constructor that makes it possible. This makes QModelIndex::parent() look suspicious if you happen to be troubleshooting a problem. If you want to be sure your model is implemented correctly, you have to put aside the docs and dig up the inline function definitions in qabstractitemmodel.h.
  • 0 Votes
    5 Posts
    3k Views
    Y
    Thank you @mrjj and @Christian for answer. I am able to make user Checkable. class CustomListModel : public QStandardItemModel { public: Qt::ItemFlags CustomListModel::flags(const QModelIndex & index) const { Qt::ItemFlags defaultFlags = QStandardItemModel::flags(index); if (index.isValid()) { return defaultFlags | Qt::ItemIsUserCheckable; } return defaultFlags; } CustomListModel(const int row, const int coloumn) : QStandardItemModel(row, coloumn) { } }; and modification. hwListProxyModel->setSourceModel(new CustomListModel (0, 0));
  • 0 Votes
    4 Posts
    2k Views
    kshegunovK
    @michelson said: Hello, I assumed i had to reimplement QItemDelegate::setModelData(...) I think this should suffice for your case. You can of course always create your own model as @SGaist suggested. As for your request for additional material: Here is an overview of the model-view framework A simple spinbox delegate example Icons example that uses delagets I hope this helps. Kind regards.
  • [SOLVED]QSqlTableModel subclass

    General and Desktop qsqlta qmodelidex
    4
    0 Votes
    4 Posts
    2k Views
    M
    Hi, internalPointer() is basically used when you use createIndex(). As I said the internal structure is not specified in the documentation; so if you want to understand the exact implementation you have to have a look in the Qt sources