You don't tell us which platform you are using. QWidget::raise() works just fine here on Linux. It's possible that it won't work on your platform before the widget is shown, i.e. after the constructor is finished. Try this:
...
templateDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
templateDock
->setWidget
(new QTextEdit(templateDock
));
addDockWidget(Qt::LeftDockWidgetArea, templateDock);
propertyDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
propertyDock
->setWidget
(new QTextEdit(propertyDock
));
addDockWidget(Qt::LeftDockWidgetArea, propertyDock);
tabifyDockWidget(templateDock, propertyDock);
// templateDock->raise(); // <<<< works here on Linux
QTimer::singleShot(0,
this,
SLOT(tweakUi
()));
// <<<< Try deferring it }
public slots:
void tweakUi() {
templateDock->raise();
}
MainWindow(QWidget *p = 0): QMainWindow(p) {
...
templateDock = new QDockWidget(tr("Template"), this);
templateDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
templateDock->setWidget(new QTextEdit(templateDock));
addDockWidget(Qt::LeftDockWidgetArea, templateDock);
propertyDock = new QDockWidget(tr("Property"), this);
propertyDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
propertyDock->setWidget(new QTextEdit(propertyDock));
addDockWidget(Qt::LeftDockWidgetArea, propertyDock);
tabifyDockWidget(templateDock, propertyDock);
// templateDock->raise(); // <<<< works here on Linux
QTimer::singleShot(0, this, SLOT(tweakUi())); // <<<< Try deferring it
}
public slots:
void tweakUi() {
templateDock->raise();
}
To copy to clipboard, switch view to plain text mode
Bookmarks