The same problem :/
In general I have a big problem with restoreState/restoreGeometry, QSettings ini file looks good after saving (objectname (is unique), dockwidget area, geometry),
[docks]
dock\1\objectName="Type_1;5"
dock\1\area=2
dock\1\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\0\0\0\0\0\0\a\x80)
dock\2\objectName="Type_2;3"
dock\2\area=2
dock\2\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\0\0\0\0\0\0\a\x80)
dock\3\objectName="Type_3;4"
dock\3\area=8
dock\3\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\0\0\a\x80)
dock\4\objectName="Type_4;7"
dock\4\area=2
dock\4\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
dock\5\objectName="Type_5;2"
dock\5\area=1
dock\5\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\0\a\x80)
dock\6\objectName="Type_6;5"
dock\6\area=1
dock\6\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
dock\7\objectName="Type_7;3"
dock\7\area=0
dock\7\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\f\x84\0\0\x2\x39\0\0\xe(\0\0\x3\x96\0\0\f\x8c\0\0\x2X\0\0\xe \0\0\x3\x8e\0\0\0\x1\0\0\0\0\a\x80)
dock\size=7
[Window]
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\x80\0\0\0\x33\0\0\x6\xc1\0\0\x3\xe1\0\0\0\x88\0\0\0R\0\0\x6\xb9\0\0\x3\xd9\0\0\0\0\0\0\0\0\a\x80)
windowState="@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x3\0\0\0\0\0\0\x1P\0\0\x2\x9c\xfc\x2\0\0\0\x2\xfb\0\0\0\x1a\0T\0\x65\0l\0\x65\0m\0\x65\0t\0r\0y\0_\0\x35\0;\0\x32\x1\0\0\0\x1e\0\0\x1\x94\0\0\x1!\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x36\0;\0\x35\x1\0\0\x1\xb4\0\0\x1\x6\0\0\x1\x4\0\xff\xff\xff\0\0\0\x1\0\0\x1j\0\0\x2\x9c\xfc\x2\0\0\0\x3\xfb\0\0\0*\0\x41\0r\0t\0i\0\x66\0i\0\x63\0i\0\x61\0l\0H\0o\0r\0i\0z\0o\0n\0_\0\x32\0;\0\x33\x1\0\0\0\x1e\0\0\x1%\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x31\0;\0\x35\x1\0\0\x1\x45\0\0\x1\x4\0\0\x1\x4\0\xff\xff\xff\xfb\0\0\0\x1a\0L\0o\0g\0P\0l\0\x61\0y\0\x65\0r\0_\0\x34\0;\0\x37\x1\0\0\x2K\0\0\0o\0\0\0o\0\xff\xff\xff\0\0\0\x3\0\0\x6\x32\0\0\0\xb8\xfc\x1\0\0\0\x1\xfb\0\0\0&\0W\0\x61\0y\0P\0o\0i\0n\0t\0s\0W\0i\0\x64\0g\0\x65\0t\0_\0\x33\0;\0\x34\x1\0\0\0\0\0\0\x6\x32\0\0\x3O\0\xff\xff\xff\0\0\x3t\0\0\x2\x9c\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0)"
size=@Size(1586 904)
pos=@Point(128 51)
[docks]
dock\1\objectName="Type_1;5"
dock\1\area=2
dock\1\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\x4\xc8\0\0\x1\x45\0\0\x6\x31\0\0\x2H\0\0\0\0\0\0\0\0\a\x80)
dock\2\objectName="Type_2;3"
dock\2\area=2
dock\2\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\x4\xc8\0\0\0\x1e\0\0\x6\x31\0\0\x1\x42\0\0\0\0\0\0\0\0\a\x80)
dock\3\objectName="Type_3;4"
dock\3\area=8
dock\3\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\x2\xbc\0\0\x6\x31\0\0\x3s\0\0\0\0\0\0\0\0\a\x80)
dock\4\objectName="Type_4;7"
dock\4\area=2
dock\4\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\x4\xc8\0\0\x2K\0\0\x6\x31\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
dock\5\objectName="Type_5;2"
dock\5\area=1
dock\5\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\x1e\0\0\x1O\0\0\x1\xb1\0\0\0\0\0\0\0\0\a\x80)
dock\6\objectName="Type_6;5"
dock\6\area=1
dock\6\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\x1\xb4\0\0\x1O\0\0\x2\xb9\0\0\0\0\0\0\0\0\a\x80)
dock\7\objectName="Type_7;3"
dock\7\area=0
dock\7\geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\f\x84\0\0\x2\x39\0\0\xe(\0\0\x3\x96\0\0\f\x8c\0\0\x2X\0\0\xe \0\0\x3\x8e\0\0\0\x1\0\0\0\0\a\x80)
dock\size=7
[Window]
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x2\0\0\0\0\0\x80\0\0\0\x33\0\0\x6\xc1\0\0\x3\xe1\0\0\0\x88\0\0\0R\0\0\x6\xb9\0\0\x3\xd9\0\0\0\0\0\0\0\0\a\x80)
windowState="@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x3\0\0\0\0\0\0\x1P\0\0\x2\x9c\xfc\x2\0\0\0\x2\xfb\0\0\0\x1a\0T\0\x65\0l\0\x65\0m\0\x65\0t\0r\0y\0_\0\x35\0;\0\x32\x1\0\0\0\x1e\0\0\x1\x94\0\0\x1!\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x36\0;\0\x35\x1\0\0\x1\xb4\0\0\x1\x6\0\0\x1\x4\0\xff\xff\xff\0\0\0\x1\0\0\x1j\0\0\x2\x9c\xfc\x2\0\0\0\x3\xfb\0\0\0*\0\x41\0r\0t\0i\0\x66\0i\0\x63\0i\0\x61\0l\0H\0o\0r\0i\0z\0o\0n\0_\0\x32\0;\0\x33\x1\0\0\0\x1e\0\0\x1%\0\0\0\xc8\0\xff\xff\xff\xfb\0\0\0\x18\0M\0\x61\0i\0n\0V\0i\0\x65\0w\0_\0\x31\0;\0\x35\x1\0\0\x1\x45\0\0\x1\x4\0\0\x1\x4\0\xff\xff\xff\xfb\0\0\0\x1a\0L\0o\0g\0P\0l\0\x61\0y\0\x65\0r\0_\0\x34\0;\0\x37\x1\0\0\x2K\0\0\0o\0\0\0o\0\xff\xff\xff\0\0\0\x3\0\0\x6\x32\0\0\0\xb8\xfc\x1\0\0\0\x1\xfb\0\0\0&\0W\0\x61\0y\0P\0o\0i\0n\0t\0s\0W\0i\0\x64\0g\0\x65\0t\0_\0\x33\0;\0\x34\x1\0\0\0\0\0\0\x6\x32\0\0\x3O\0\xff\xff\xff\0\0\x3t\0\0\x2\x9c\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0)"
size=@Size(1586 904)
pos=@Point(128 51)
To copy to clipboard, switch view to plain text mode
but after loading it looks bad:| (especially in case when added before new dockwidgets, and removed some of old) :/
this is how i load it
settings.beginGroup("docks");
int DocksCount = settings.beginReadArray("dock");
if(DocksCount > 0)
{
for(int i = 0; i < DocksCount; i++)
{
settings.setArrayIndex(i);
QString objectName
= settings.
value("objectName").
toString();
if(dock)
{
Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(settings.value("area").toInt());
this->addDockWidget(area, dock);
dock->restoreGeometry(settings.value("geometry").toByteArray());
}
}
}
settings.endArray();
settings.endGroup();
settings.beginGroup("Window");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
resize
(settings.
value("size",
QSize(1200,
800)).
toSize());
move
(settings.
value("pos",
QPoint(0,
0)).
toPoint());
QSettings settings(QApplication::applicationDirPath() + fileini, QSettings::IniFormat);
settings.beginGroup("docks");
int DocksCount = settings.beginReadArray("dock");
if(DocksCount > 0)
{
for(int i = 0; i < DocksCount; i++)
{
settings.setArrayIndex(i);
QString objectName = settings.value("objectName").toString();
QDockWidget* dock = addSubWindow(objectName);
if(dock)
{
Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(settings.value("area").toInt());
this->addDockWidget(area, dock);
dock->restoreGeometry(settings.value("geometry").toByteArray());
}
}
}
settings.endArray();
settings.endGroup();
settings.beginGroup("Window");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
resize(settings.value("size", QSize(1200, 800)).toSize());
move(settings.value("pos", QPoint(0, 0)).toPoint());
To copy to clipboard, switch view to plain text mode
any help?
Regards,
DizL
Bookmarks