Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Use QDesktopwidget::availableGeometry to show QMainWindow maximized
Qt 6.11 is out! See what's new in the release blog

Use QDesktopwidget::availableGeometry to show QMainWindow maximized

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MvHorssen
    wrote on last edited by
    #1

    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)

    kshegunovK 1 Reply Last reply
    0
    • M MvHorssen

      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)

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved