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

Blank window using two screens



  • Hello!!

    This is a little strange issue. I am using two screens, and I have an application that opens different windows.

    One of these windows, has a little problem. These are the steps for reproduce the issue:

    1. Open the window.
    2. Move the window to the second screen.
    3. Close the window.
    4. Open the window again. The window appears blank and when I click the area in which there is a widget, the window shows normal again.

    Could you help me with this??

    Thank you very much!


  • Qt Champions 2019

    Which Qt version do you use? Can you please provide a minimal, compilable example to reproduce the problem / we can see what you're actually doing?



  • I found a solution:

    Use this code in the part where you want to show the window:

    if (QApplication::desktop()->screenCount() > 1) {
        myWindow->setGeometry(
            QStyle::alignedRect(Qt::LeftToRight, 
                                Qt::AlignCenter, 
                                myWindow->size(), 
                                QApplication::desktop()->availableGeometry(0)));
    }
    myWindow->show();
    

    This solves my problem


Log in to reply