Placing windows on the screen with QT

-1

I'm doing an application in C ++ using QT Creator that opens several windows at the same time. The problem is that all are placed one above the other, what is the operation that allows to place the windows in a specific part of the screen ?. Greetings.

    
asked by user3224353 06.05.2018 в 14:22
source

1 answer

1

With the void setGeometry (int x, int and, int width, int height) you can define the position of the upper left corner and its width and height.

An example:

#include <QApplication>
#include <QWidget>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w1,w2,w3,w4;
    w1.setGeometry(50,0,200,200);
    w2.setGeometry(300,0,200,200);
    w3.setGeometry(50,300,200,200);
    w4.setGeometry(300,300,200,200);
    w1.show();
    w2.show();
    w3.show();
    w4.show();
    return a.exec();
}

This shows you four windows with an initial position and dimensions. This feature can be found in the QDesigner, if you are designing the window there.

    
answered by 08.05.2018 / 19:21
source