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. Why itemChanged of QStandardItemModel is invoked on all items on my model when creating the QStandardItemModel subclass
QtWS25 Last Chance

Why itemChanged of QStandardItemModel is invoked on all items on my model when creating the QStandardItemModel subclass

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 4.4k 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.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Hi i have model subclass m_model ( of QStandardItemModel ) it contains QStandardItem's that one of its column has setCheckable(true)
    in the subclass in the constructor i have this single/slot wired:
    @connect(m_model, SIGNAL(itemChanged(QStandardItem*)), this,
    SLOT(tree_itemChanged(QStandardItem*))); @

    why each time i create the m_model and it happen only once it iterate all the items in my model with the tree_itemChanged method ?
    i want it to be invoked only when i check/unchecked the check box.

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      bq. why each time i create the m_model and it happen only once it iterate all the items in my model with the tree_itemChanged method ?
      i want it to be invoked only when i check/unchecked the check box.

      If I 'm not wrong you have a QStandardItemModel that you use also for a tree?

      What does your SLOT tree_itemChanged do?
      You could use a condition to filter only the checked role.

      Can you elaborate a little more about the structure of your application? Do you use a proxymodel?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        What do you do in the constructor of your subclassed model? And how and where do you populate it?

        Additionally, you can set a breakpoint in you slot and look at the call stack from where the signal was triggered.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • U Offline
          U Offline
          umen242
          wrote on last edited by
          #4

          Hi
          Eddy the tree_itemChanged checks if the check box checked or not and i do filter with if/else
          Volker i did see the stack , its trigger from where i iniT the object with new operator

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            So, what do you do in the constructor?

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • U Offline
              U Offline
              umen242
              wrote on last edited by
              #6

              in my main app class i do
              @TreeViewWindowContainer* pTreeViewWindowContainer= new TreeViewWindowContainer();@

              TreeViewWindowContainer is my QStandardItemModel subclass

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                No surprise in that.

                How do you populate the model?

                http://www.catb.org/~esr/faqs/smart-questions.html

                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