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. QCheckBox to hide QTableWidget
Forum Updated to NodeBB v4.3 + New Features

QCheckBox to hide QTableWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 293 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
    Phamy1289
    wrote on last edited by
    #1

    I want to have a checkbox, very bottom named "Hide All", that hides the table of information. So far, when I click on it, nothing happens.

    Screenshot from 2021-10-20 15-32-29.png
    QCheckBox *hideCheckBox = new QCheckBox("Hide All", pTable);

    // pTable->setVisible(false);

    if(hideCheckBox->checkState() == Qt::Checked)
    {
        pTable->setVisible(false);
    }
    
    if(hideCheckBox->checkState() == Qt::Unchecked)
    {
        pTable->setVisible(true);
    }
    
    
    
    
    pVBox->addWidget(pHeader);
    pVBox->addWidget(pTable);
    pVBox->addWidget(hideCheckBox);
    
    pGroupBox->setLayout(pVBox);
    
    return pGroupBox;
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you calling that code from a slot connected to the QCheckBox::stateChanged signal ?

      In any case, it could be simplified:

      pTable->setVisible(hideCheckBox->checkState() == Qt::Unchecked);
      

      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
      1

      • Login

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