Qt World Summit: Submit your Presentation

QTreeView - rename notify

  • Hey

    How can I get notified when I 2x click on item and change its name? Is there a signal or something that can tell me which item/role got updated?

    Or I need to subclass the view/model/item etc to get that?


  • Hmmm

    So I run

        connect(mModelActionList, &QStandardItemModel::dataChanged, this, &icActionManager::actionDataChanged);

    But that does not give me the role for some reason. I get this from debug

        void actionDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
        qDebug() << topLeft << bottomRight << roles;
    QModelIndex(0,0,0x20324b0f7c0,QStandardItemModel(0x2032470f510)) QModelIndex(0,0,0x20324b0f7c0,QStandardItemModel(0x2032470f510)) QVector()

    Bit strange... is it just a full refresh?

  • What model are you using? QStandardItemModel had the roles argument working from Qt 5.11 onward. An empty role vector implies "all roles changed"