Mainwindow offcenter in linux



  • 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?



  • 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).



  • Interesting, thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.