Search code examples
c++qtgeometryqrect

how to work with Geom in QT?


geom does not work right. When you define a new position for the window, part of it is off screen. How to solve this problem?

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QRect test(0,0,300,240);
    setGeometry(test);
}

MainWindow::~MainWindow()
{
    delete ui;
}

Solution

  • Solved:

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        QRect test(0,0,300,240);
        setGeometry(test);
        move(0,0);//Fix
    }