-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
4.7.4, 5.2.0
-
None
-
Ubuntu 11.10
Note: I didn't find any GUI category where to put this bug, so I choose Widgets.
If you call
layout()->setSizeConstraint(QLayout::SetFixedSize)
on the mainwindow, your application will have a fixed size and you can't resize it. However, if later you call
layout()->setSizeConstraint(QLayout::SetDefaultConstraint)
, the application is still unresizable.
So I changed the windowflags so that qt would reset the window (to add the maximize button, for one), and called show() on the main window again. Now the window is resizable but only to a certain size, there are still wild restrictions applied to it.
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); public slots: void changeCentralWidget(); }; #endif // MAINWINDOW_H
#include "mainwindow.h" #include <QtGui> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { show(); setCentralWidget(new QPushButton("hello, this is a test................")); layout()->setSizeConstraint(QLayout::SetFixedSize); connect(centralWidget(), SIGNAL(clicked()), SLOT(changeCentralWidget())); } void MainWindow::changeCentralWidget() { layout()->setSizeConstraint(QLayout::SetDefaultConstraint); setCentralWidget(new QTextEdit(QString::number(windowFlags(), 16))); layout()->setSizeConstraint(QLayout::SetDefaultConstraint); /* Adds the possibility to resize the window */ setWindowFlags(windowFlags() ^ Qt::WindowMinMaxButtonsHint); setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint); show(); }
Context
I have an application with an image as a menu, and as such fixed size. But then when the user gets into different functionalities, they make the window have a different layout and be resizable. For now what I do is create a new QMainWindow and delete the old one everytime, however now on ubuntu if you have another app on the same screen, it makes my application go behind it. That's why I'm submitting this bug report. I've had this bug since I started, around Qt 4.5, and on windows too.