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. QTreeWidgetItem checkState() signal and slot?
Qt 6.11 is out! See what's new in the release blog

QTreeWidgetItem checkState() signal and slot?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 6.8k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pditty8811
    wrote on last edited by
    #1

    How do I implement a QTreeWidgetItem checkState() signal and slot?

    I have a child QTreeWidgetitem that I want to deliver a signal if it is checked or unchecked, so the parent treewidgetitem will uncheck too. Sort of like a full packge install, that unchecks the parent box if just one of the child boxes are unchecked.

    I'm learning signals and slots implementation without the ui, just now.

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

      Hi,

      You don't do it on the items (they are not QObject), but in the QTreeWidget using e.g.
      @QTreeWidget::itemChanged ( QTreeWidgetItem * item, int column )@

      Connect that signal to a custom slot and handle there the modification of your items.

      Hope it helps

      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
      3
      • sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by
        #3
        TWI->setCheckState(column, Qt::Checked);
        connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(treeWidgetItemChanged(QTreeWidgetItem*, int)));
        
        void MainWindow::treeWidgetItemChanged(QTreeWidgetItem *TWI, int column)
        {
            if (TWI->checkState(column) == Qt::Checked){
                ......
            } 
        }
        

        https://github.com/sonichy

        1 Reply Last reply
        1

        • Login

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