Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QStandardItemModel's dataChanged signal doesn't get emitted
QtWS25 Last Chance

[SOLVED] QStandardItemModel's dataChanged signal doesn't get emitted

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 7.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    XGuy
    wrote on last edited by
    #1

    I have a QStandardItemModel attached to a QlistView, and i want to catch it's dataChanged signal however i can't. here is my code:
    this code is inside the constructor:
    @modelProvider = new QStandardItemModel(this);
    bool rv = false;
    rv = QObject::connect(modelProvider, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(datachanged(QModelIndex,QModelIndex)));@

    connect returns true in rv!

    and here is my slot implementation:
    @void MyClass::datachanged(QModelIndex index, QModelIndex index2)
    {
    QMessageBox::information(this, "test", "test");
    }@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Where do you change your model data ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • X Offline
        X Offline
        XGuy
        wrote on last edited by
        #3

        Hi,
        inside my class i have a function which creates the model based on data read from a file:
        @
        void MyClass::getProvider()
        ...
        itemProvider = new QStandardItem(objStructProvider.Name);
        modelProvider->appendRow(itemProvider);
        itemProvider->setEditable(true);
        ...
        @
        and i want to catch dataChanged signal of model(modelProvider) when user has changed the item(itemProvider) text inside model(modelProvider).

        by changing item text i mean: user double clicks on an item and the item enters editing state so that he can change it's text.
        thx 4 ur reply.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thEClaw
          wrote on last edited by
          #4

          Did you try the "itemChanged()-signal":http://qt-project.org/doc/qt-5.1/qtgui/qstandarditemmodel.html#itemChanged too?

          1 Reply Last reply
          0
          • X Offline
            X Offline
            XGuy
            wrote on last edited by
            #5

            The problem is solved!
            i was initializing my Model for 2 times.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved