PDA

View Full Version : Unable to hide QTableWidget in QVBoxLayout



rawfool
9th June 2013, 13:14
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.



// 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, 0, new QTableWidgetItem(lst.at(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.

Santosh Reddy
10th June 2013, 08:01
Remove the if conditions


...
// if(cceReference_table->isVisible())
// {
cceReference_table->setVisible(false);
// }
...
//if(!cceReference_table->isVisible())
// {
cceReference_table->setVisible(true);
// }
...