QCheckBox to hide QTableWidget
Unsolved
General and Desktop
-
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.
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;
-
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);