PDA

View Full Version : QDockWidget -> Reset all



pl01
24th March 2011, 11:47
Hi,

I have several QDockWidgets in my app. But I have closed one of them !

Now, when I restore the state it does not appear. The problem is that I don't know how to reset my layout and force to redisplay the docking widget !

Do you have an idea ?

Thks

agarny
24th March 2011, 12:14
Now, when I restore the state it does not appear. The problem is that I don't know how to reset my layout and force to redisplay the docking widget !I have a reset all feature in my application to, among other things, address the kind of problem you came across. Here is what I currently use:


if( QMessageBox::question(this, qApp->applicationName(),
tr("You are about to reset <strong>all</strong> of your user settings. Are you sure that this is what you want?"),
QMessageBox::Yes|QMessageBox::No,
QMessageBox::Yes) == QMessageBox::Yes ) {
// Clear all the user settings and restart <APP> (indeed, a restart
// will ensure that the various dock windows are, for instance, properly
// reset with regards to their dimensions)

QSettings(qApp->applicationName()).clear();

// Restart <APP>, but without providing any of the argument with which
// <APP> was originally started, since we indeed want to reset
// everything

QProcess::startDetached(qApp->applicationFilePath(), QStringList(),
qApp->applicationDirPath());

// Quit <APP>
// Note: the closeEvent method won't get called and this is exactly what
// we want, since we don't want to save <APP>'s settings

qApp->quit();
}

pl01
24th March 2011, 13:11
Thanks,

The problem is that I don't want to restart the application !

If I do this :

addDockWidget(static_cast<Qt::DockWidgetArea>(1), ui.dockWidget_left);
ui.dockWidget_left->raise();
ui.dockWidget_right->setFloating(false);
ui.dockWidget_left->show();

Everything works... I only redisplay them as docked at the default place.

Thanks for your help