Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.7, 6.8.0
-
Windows 10 22H2, MSVC 2022 x64
-
-
90be6609b (dev), 2c1a23f3c (6.8), f7da1103e (tqtc/lts-6.5)
Description
Frameless QWidgets have this issue; frameless non-Qt windows do not.
Code
#include <QtWidgets> #include <windows.h> static QLabel *label = nullptr; static void adjustWorkArea(int height_delta) { RECT rect; SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0); rect.top += height_delta; SystemParametersInfo(SPI_SETWORKAREA, 0, &rect, SPIF_UPDATEINIFILE); label->setText( QStringLiteral( "Offset: %1\n\n" "Remember to restore the offset to 0!" ) .arg(rect.top) ); } int main(int argc, char *argv[]) { QApplication app(argc, argv); auto btn_increaseOffset = new QPushButton("Increase work area offset"); auto btn_decreaseOffset = new QPushButton("Decrease work area offset"); label = new QLabel; auto checkbox_frameless = new QCheckBox("Frameless?"); auto btn_maximize = new QPushButton("Maximize"); auto btn_restore = new QPushButton("Restore"); QWidget win; auto layout = new QVBoxLayout(&win); layout->addWidget(btn_increaseOffset); layout->addWidget(btn_decreaseOffset); layout->addWidget(label); layout->addWidget(checkbox_frameless); layout->addWidget(btn_maximize); layout->addWidget(btn_restore); win.resize(400, 300); win.show(); adjustWorkArea(0); QObject::connect(btn_increaseOffset, &QPushButton::clicked, qApp, [] { adjustWorkArea(50); }); QObject::connect(btn_decreaseOffset, &QPushButton::clicked, qApp, [] { adjustWorkArea(-50); }); QObject::connect(checkbox_frameless, &QCheckBox::stateChanged, qApp, [&] { win.setWindowFlag(Qt::FramelessWindowHint, (checkbox_frameless->checkState() == Qt::Checked)); win.show(); }); QObject::connect(btn_maximize, &QPushButton::clicked, qApp, [&] { win.showMaximized(); }); QObject::connect(btn_restore, &QPushButton::clicked, qApp, [&] { win.showNormal(); }); return app.exec(); }
Steps to reproduce
- Build and run the attached code
- Click "Increase work area offset" to get a non-zero offset
- Maximize the widget (click the "Maximize" button, or use the [Win]+[↑] keyboard shortcut)
- Restore the widget
- Check the "Frameless?" checkbox
- Maximize the widget
- Build and run the code at https://github.com/melak47/BorderlessWindow
- Maximize that non-Qt borderless window (use the [Win]+[↑] keyboard shortcut)
- Click "Decrease work area offset" to get a zero offset before quitting
Outcomes
- Step #3: The framed QWidget is maximized with an offset at the top of the screen (Expected)
- Step #6: The frameless QWidget is maximized with an offset at the bottom of the screen (Not Expected)
- Step #8: The frameless non-Qt window is maximized with an offset at the top of the screen (Expected)
Attachments
Issue Links
- replaces
-
QTBUG-129791 Issue with Showmaximized function in case of QMainWindow with Qt::FramelessWindowHint flag
-
- Closed
-