Ok... is there a way to iterate through all widgets in a widget so I can store the internal geometry? It's easy for me to store my main widget's geometry by just using the geometry() and setGeometry() functions in conjunction with QSettings... but I see no easy way to do so with internal widgets. This means that if one widget's separator was moved to make one smaller and one larger, this is not preserved the next time the app is run.
I had thought that I could run through the below code to make it work, but it's behaving strangely as I do so (taken from my main window's code):
for(int index(0); index < myLayout->count(); index++)
{
QWidget * child
= myLayout
->itemAt
(index
)->widget
();
if(child)
{ //Then it must really be a widget and not a layout
if(!settings.value("geometry").isNull())
{
child->setGeometry(settings.value("geometry").toRect());
}
settings.endGroup();
}
}
QLayout * myLayout = layout();
for(int index(0); index < myLayout->count(); index++)
{
QWidget * child = myLayout->itemAt(index)->widget();
if(child)
{ //Then it must really be a widget and not a layout
QSettings settings;
settings.beginGroup(QString("geometry/") + QString::number(index));
if(!settings.value("geometry").isNull())
{
child->setGeometry(settings.value("geometry").toRect());
}
settings.endGroup();
}
}
To copy to clipboard, switch view to plain text mode
Simple-looking stuff... but it seg-faults on startup (specifically, on the 3rd run of line 4)
It prints:
QMainWindowLayout::count()
QMainWindowLayout::count()
QMainWindowLayout::count()
Segmentation fault
I'm kinda at a loss at this point
Bookmarks