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. Can i attach to QStandardItem check state a signal to know its state ? without subclassing.
QtWS25 Last Chance

Can i attach to QStandardItem check state a signal to know its state ? without subclassing.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 11.3k 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 simple QStandardItem that one of its column is setCheckable(true);
    i didnt found any signal i can attach to it , so i could trigger function on check box state .
    how can i attach one without sub classing the QStandardItem.
    Thanks

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      "QStandardItemModel::itemChanged":http://doc.qt.nokia.com/latest/qstandarditemmodel.html#itemChanged

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

        its not working for me .
        here what i have :

        @connect(ui.treeView_mainwindow, SIGNAL(itemChanged( const QModelIndex &)), this,
        SLOT(tree_itemChanged( const QModelIndex &)));

        // this function never fired when i check in/out
        tree_itemChanged(const QModelIndex & index)
        {

         QStandardItem* standardItem  = m_model->itemFromIndex(index);
         Qt::CheckState checkState = standardItem->checkState();
         if(checkState == Qt::Checked)
         {
            WRITELOG("Qt::Checked")
            
         }
         else if(checkState == Qt::Unchecked)
         {
            WRITELOG("Qt::Unchecked")
         }
        

        }@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          itemChanged is a signal from QStandardItemModel, not from (I think) a QTreeView

          The signature is wrong as well (it passes a QStandardItem* and not a QModelIndex).

          Tip: when developing, enable debug and check the console. A connect() that fails will return false and print a warning on the console.

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

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

            Thanks working

            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