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. Mainwindow offcenter in linux
Qt 6.11 is out! See what's new in the release blog

Mainwindow offcenter in linux

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k 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.
  • J Offline
    J Offline
    jocala
    wrote on last edited by
    #1

    I have a situation where my main window opens in the upper left of the monitor, only under linux. It looks quite strange, especially when a informational popup appears at program start, that is properly centered where mainwindow is on Mac and Windows! Screenshot below:

    http://jocala.com/images/afpic.png

    How can I fix this Linux issue?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      I am not sure how you center your window so I have no suggestions.

      I don't center the window but store the last size and location in a settings file. I use the following in the constructor:

      @
      Position = d_Settings->value("Mainwindow_Position", QPoint(30,30)).toPoint();
      Size = d_Settings->value("Mainwindow_Size", QSize(800, 509)).toSize();

      DesktopRect = QApplication::desktop()->availableGeometry();

      WidgetRect.moveTopLeft(Position);
      WidgetRect.setSize(Size);

      WidgetRect = WidgetRect & DesktopRect;

      if(WidgetRect.isValid())
      {
      this->resize(WidgetRect.size());
      this->move(WidgetRect.topLeft());
      }
      else
      {
      this->resize(QSize(800, 509));
      this->move(QPoint(30,30));
      }
      @

      The intersected() function '&' makes sure the window is not off the desktop (somewhere you can't get to it).

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jocala
        wrote on last edited by
        #3

        Interesting, thank you!

        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