Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] how to work with Geom in QT?

    General and Desktop
    3
    6
    1245
    Loading More Posts
    • 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.
    • B
      brcontainer last edited by

      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;
      }@

      Solved:
      I was testing various functions QMainWindow and found the move()

      @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
      

      }@

      QT project: https://github.com/brcontainer/qt-helper

      1 Reply Last reply Reply Quote 0
      • S
        skycrestway last edited by

        See the documentation for QWidget. See functions frameGeometry(), x(), y(), pos().

        1 Reply Last reply Reply Quote 0
        • B
          brcontainer last edited by

          Could you give me an example? Thanks

          QT project: https://github.com/brcontainer/qt-helper

          1 Reply Last reply Reply Quote 0
          • JKSH
            JKSH Moderators last edited by

            http://qt-project.org/doc/qt-5.0/qtwidgets/application-windows.html#window-geometry

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply Reply Quote 0
            • S
              skycrestway last edited by

              The documentation explains why the frameGeometry is different than the geometry. Basically it is because of the frame that is put around the widget by the operating systems window manager. Different window managers use different size frames. It is not possible to know the frameGeometry until after the window has been displayed.

              The best practice is to set the size of the widget with resize() and let the window manager set the location of it.

              1 Reply Last reply Reply Quote 0
              • B
                brcontainer last edited by

                Solved:

                I found the answer to this problem.

                @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
                

                }@

                QT project: https://github.com/brcontainer/qt-helper

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post