Details
-
Bug
-
Resolution: Done
-
P4: Low
-
4.6.2
-
None
-
5e99b07a072bedee239ed6980a44719da9ffa7c9
Description
When window flags are set for the QMdiSubWindow, after this window has been created, the change doesn't happen correctly. A workaround for this problem is to set a parent for the sub window, since this will cause the internal private function to be called and the properties to be updated correctly.
Example with an implemented workaround
#include <QtGui> class ControlWidget : public QMdiArea { Q_OBJECT public: ControlWidget(QWidget *parent = 0) : QMdiArea(parent) { QPushButton *pb = new QPushButton("Swap flags"); addSubWindow(pb); swFrameless = addSubWindow(new QTextEdit, Qt::FramelessWindowHint); swWithFrame = addSubWindow(new QTextEdit); originalWindowFlags = swWithFrame->windowFlags(); swap = true; connect(pb, SIGNAL(clicked()), this, SLOT(swapFlags())); } public slots: void swapFlags() { if (swap) { QRect geo1 = swWithFrame->geometry(); swWithFrame->setWindowFlags(Qt::FramelessWindowHint); swWithFrame->setParent(0); addSubWindow(swWithFrame); swWithFrame->setGeometry(geo1); QRect geo2 = swFrameless->geometry(); swFrameless->setWindowFlags(originalWindowFlags); swFrameless->setParent(0); addSubWindow(swFrameless); swFrameless->setGeometry(geo2); } else { QRect geo1 = swWithFrame->geometry(); swWithFrame->setWindowFlags(originalWindowFlags); swWithFrame->setParent(0); addSubWindow(swWithFrame); swWithFrame->setGeometry(geo1); QRect geo2 = swFrameless->geometry(); swFrameless->setWindowFlags(Qt::FramelessWindowHint); swFrameless->setParent(0); addSubWindow(swFrameless); swFrameless->setGeometry(geo2); } swWithFrame->show(); swFrameless->show(); swap = !swap; } private: QMdiSubWindow *swFrameless; QMdiSubWindow *swWithFrame; Qt::WindowFlags originalWindowFlags; bool swap; }; #include "main.moc" int main(int argc, char *argv[]) { QApplication app(argc, argv); ControlWidget area; area.show(); return app.exec(); }