QDialog Showmaximized not working
-
After days of research I found that the bug is still there almost 10 years after report.
This is important for anybody using QinputDialog Ubuntu (I tested on Ubuntu 22.04) : showMaximized() and showNormal() have issues changing the state. This makes setGeometry troublesome as well.https://bugreports.qt.io/browse/QTBUG-16034
I spend hours searching this forum and others finally finding the bug report.
So if moderators allow let's have it here for record of others searching for the cause.
-
S Seb Tur has marked this topic as solved on
-
After days of research I found that the bug is still there almost 10 years after report.
This is important for anybody using QinputDialog Ubuntu (I tested on Ubuntu 22.04) : showMaximized() and showNormal() have issues changing the state. This makes setGeometry troublesome as well.https://bugreports.qt.io/browse/QTBUG-16034
I spend hours searching this forum and others finally finding the bug report.
So if moderators allow let's have it here for record of others searching for the cause.
@Seb-Tur
That issue refers to "metacity" under GNOME. I don't know that it has general/any applicability nowadays. It also is about whether min/max buttons can be shown on a dialog, whereas you seem to be asking about code.FWIW I tried under 22.04 and it seemed to work OK. Default GNOME/Mutter.
showMaximized()
seem to work from code. I cannot be sure what else you saw for "troublesome". -
@Seb-Tur
That issue refers to "metacity" under GNOME. I don't know that it has general/any applicability nowadays. It also is about whether min/max buttons can be shown on a dialog, whereas you seem to be asking about code.FWIW I tried under 22.04 and it seemed to work OK. Default GNOME/Mutter.
showMaximized()
seem to work from code. I cannot be sure what else you saw for "troublesome".tested again on mine,
QDialog dialog(parent_widget); dialog.setObjectName("messageDialog"); dialog.setWindowIcon(icon); dialog.setWindowTitle(title); dialog.setWindowFlags(Qt::Window); dialog.showMaximized(); bool res = dialog.exec()
if I skip setWindowFlags(Qt::Window) then dialog is not maximized at all
-
tested again on mine,
QDialog dialog(parent_widget); dialog.setObjectName("messageDialog"); dialog.setWindowIcon(icon); dialog.setWindowTitle(title); dialog.setWindowFlags(Qt::Window); dialog.showMaximized(); bool res = dialog.exec()
if I skip setWindowFlags(Qt::Window) then dialog is not maximized at all
-
S Seb Tur has marked this topic as unsolved on
-
Reopening,
now I tried to make a windows10 build for my app and show dialog.showMaxmized() does not work, the window is just a fraction of the screen.this is how i do it:
if (touchscreen) { qDebug()<<"Showing maximized, it is touchscreen"; setWindowFlags(windowFlags() | Qt::Window); setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); showMaximized(); } else { qDebug()<<"no touchscreen, getting screen geometry and calculate the size to occupy half of the screen";; QRect screenGeometry = QApplication::primaryScreen()->geometry(); int width = screenGeometry.width() / 2; int height = screenGeometry.height() / 2; int x = (screenGeometry.width() - width) / 2; int y = (screenGeometry.height() - height) / 2; // Set the geometry of the dialog to be centered and occupy half the screen setGeometry(x, y, width, height); show(); } exec();
-
Reopening,
now I tried to make a windows10 build for my app and show dialog.showMaxmized() does not work, the window is just a fraction of the screen.this is how i do it:
if (touchscreen) { qDebug()<<"Showing maximized, it is touchscreen"; setWindowFlags(windowFlags() | Qt::Window); setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); showMaximized(); } else { qDebug()<<"no touchscreen, getting screen geometry and calculate the size to occupy half of the screen";; QRect screenGeometry = QApplication::primaryScreen()->geometry(); int width = screenGeometry.width() / 2; int height = screenGeometry.height() / 2; int x = (screenGeometry.width() - width) / 2; int y = (screenGeometry.height() - height) / 2; // Set the geometry of the dialog to be centered and occupy half the screen setGeometry(x, y, width, height); show(); } exec();
@Seb-Tur said in QDialog Showmaximized not working:
Showing maximized, it is touchscreen
Is this printed if you run your app?
-
yes it is printed
I also do check
qDebug()<<"isMaximized: "<<isMaximized();
which returns 1 after showMaximized() even if the window does not get maximized.my dirty trick right now is to add
#ifdef Q_OS_WIN QWidget *parentWidget = static_cast<QWidget *>(parent()); if (parentWidget) setGeometry(parentWidget->geometry()); #endif
just after showMaximized()