Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] how to work with Geom in QT?
Forum Updated to NodeBB v4.3 + New Features

[Solved] how to work with Geom in QT?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.7k Views 1 Watching
  • 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 Offline
    B Offline
    brcontainer
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      skycrestway
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • B Offline
        B Offline
        brcontainer
        wrote on last edited by
        #3

        Could you give me an example? Thanks

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

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          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
          0
          • S Offline
            S Offline
            skycrestway
            wrote on last edited by
            #5

            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
            0
            • B Offline
              B Offline
              brcontainer
              wrote on last edited by
              #6

              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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved