Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Use QDesktopwidget::availableGeometry to show QMainWindow maximized



  • I'm building a QT application for Windows 7, using MinGW. In my code, I have a class derived from QMainWindow. This mainwindow is showed and closed several times (over different screens). I'm showing the window using the following code:

    this->blockSignals(true);
    this->close();
    this->blockSignals(false);
    this->showMaximized();
    this->setGeometry(QApplication::desktop()->availableGeometry(mDisplayNumber));

    Only the first time when this code is exectued, the window is showed as expected. The next times, the window is showed maximized, but i'm missing a few pixels at the bottom of the screen.

    I also receive a warning in QT, when the code is executed:

    setGeometryDp: Unable to set geometry 1600x1172+0+0 on QWidgetWindow/'CDisplayClassWindow'. Resulting geometry: 1600x1150+0+22 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 780x539, maximum size: 16777215x16777215).

    What i don't understand is that the geometry returned by desktop() >availableGeometry looks like to be incorrect. My question is, how can i determine the geometry showed in the warning message?(1600x1150+0+22)


  • Qt Champions 2017

    @MvHorssen
    Hello,
    If I'm understanding correctly what you're attempting, just use QWidget::showFullScreen. Also I don't see a reason why you'd want to block the signals, could you elaborate on that?

    Kind regards.


Log in to reply