Hey guys, I have a QGridLayout inside a QFrame inside a QScrollArea. The QGridLayout holds lots of widgets.
Each time a widget is added or removed, it runs this method:
Notes:
-TabBar is the main class; it is a QWidget
-The updateLayout method is called whenever a tab is added or removed
-tabLayoutScroller is a QScrollArea
-tabLayout is a QGridLayout inside a QFrame. The QFrame is set as the main widget for tabLayoutScroller
-tabs is a QList<QPushButton*>
void TabBar::updateLayout()
{
tabLayoutScroller->setUpdatesEnabled(false);
for(int i = 0; i < tabLayout->columnCount(); i++)
{
if(!(tabLayout->itemAtPosition(0, i)))
break;
tabLayout->itemAtPosition(0, i)->widget()->hide();
tabLayout->itemAtPosition(0, i)->widget()->deleteLater();
delete tabLayout->itemAtPosition(0, i);
}
while ((child = tabLayout->takeAt(0)) != 0)
delete child;
tabLayout->invalidate();
for(int i = 0; i < tabs.count(); i++)
tabLayout->addWidget(tabs.at(i), 0, tabLayout->columnCount());
tabLayoutScroller->setUpdatesEnabled(true);
tabLayoutScroller->update();
tabLayoutScroller->repaint();
}
void TabBar::updateLayout()
{
tabLayoutScroller->setUpdatesEnabled(false);
for(int i = 0; i < tabLayout->columnCount(); i++)
{
if(!(tabLayout->itemAtPosition(0, i)))
break;
tabLayout->itemAtPosition(0, i)->widget()->hide();
tabLayout->itemAtPosition(0, i)->widget()->deleteLater();
delete tabLayout->itemAtPosition(0, i);
}
QLayoutItem *child;
while ((child = tabLayout->takeAt(0)) != 0)
delete child;
tabLayout->invalidate();
for(int i = 0; i < tabs.count(); i++)
tabLayout->addWidget(tabs.at(i), 0, tabLayout->columnCount());
tabLayoutScroller->setUpdatesEnabled(true);
tabLayoutScroller->update();
tabLayoutScroller->repaint();
}
To copy to clipboard, switch view to plain text mode
The problem is, if I have lots of widgets open, and I close lots of them, then open lots of them... the visuals glitch out quite a bit. See:
http://i.imgur.com/oer5q.png
This is an odd problem that I have yet to figure out. Any help is highly appreciated; thanks all.
Bookmarks