Unable to hide QTableWidget in QVBoxLayout
I'm trying to alter with the visibility of a QTableWidget that's added in QVBoxLayout in constructor of a dialog which pops-up on some conditions. By default, I'm adding the QTableWidget to the constructor along with some other widgets.
Based on a condition, I'm trying to set the visibility of the table.
But it happens like QTableWidget always visible on the layout and not getting hidden.
Code:
// I need to hide in "if" case and show in "else if" case on a QDialog with other widgets
if("CVE" == repoType) // This is one condition
{
if(cceReference_table->isVisible())
{
cceReference_table->setVisible(false);
}
for(int i = 0; i < lst.count(); i++)
{
cveReferences.
append(new QLabel());
cveReferences.at(i)->setText("<a href=\"" + references.value(lst.at(i)) + "\">" +
lst.at(i) + "</a>");
cveReferences.at(i)->setTextFormat(Qt::RichText);
cveReferences.at(i)->setTextInteractionFlags(Qt::TextBrowserInteraction);
cveReferences.at(i)->setOpenExternalLinks(true);
vLyt->addWidget(cveReferences.at(i));
}
}
else if("CCE" == repoType)
{
if(!cceReference_table->isVisible())
{
cceReference_table->setVisible(true);
}
cceReference_table->setRowCount(lst.count());
for(int i = 0; i < lst.count(); i++)
{
cceReference_table
->setItem
(i,
1,
new QTableWidgetItem(references.
value(lst.
at(i
))));
}
}
I need to hide the QTableWidget from the QVBoxLayout. Is there any way to do this for getting desired result? Thank you.
Re: Unable to hide QTableWidget in QVBoxLayout
Remove the if conditions
Code:
...
// if(cceReference_table->isVisible())
// {
cceReference_table->setVisible(false);
// }
...
//if(!cceReference_table->isVisible())
// {
cceReference_table->setVisible(true);
// }
...