Qt Forum

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

    Qt Academy Launch in California!

    Unsolved mapToGlobal, wrong values with Linux

    Qt 6
    maptoglobal linux ubuntu 6.3.1 bad
    4
    8
    273
    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.
    • G
      gmat last edited by

      So I created a simple stupid program that creates a main window and prints out the mapToGlobal values, the MainWindow snipit:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      
      void MainWindow::on_testPushButton_clicked()
      {
          qDebug() << "MainWindow mapToGlobal" << this->mapToGlobal(QPoint(0,0));
      }
      
      

      On Windows and macOS this works perfectly. On a fresh install of Ubuntu 22.04 I move the window around the screen and get values like:

      14:48:08: Debugging /home/user/projects/test/build/test ...
      MainWindow mapToGlobal QPoint(12,120)
      MainWindow mapToGlobal QPoint(180,1800)
      MainWindow mapToGlobal QPoint(552,5520)
      MainWindow mapToGlobal QPoint(654,6540)
      MainWindow mapToGlobal QPoint(831,8310)
      MainWindow mapToGlobal QPoint(900,9000)
      MainWindow mapToGlobal QPoint(1002,10020)
      

      Just so you know, the display resolution is 2048x1280.

      Has anyone else experienced this ?

      1 Reply Last reply Reply Quote 0
      • M
        mchinand last edited by

        What is the value of this->pos() at the same time you call mapToGlobal(QPoint(0,0))? I woud think it should be close but will differ slightly since I think pos() includes the Window frame when reporting the position when the widget is a window.

        JonB 1 Reply Last reply Reply Quote 0
        • G
          gmat last edited by

          yes, it is not much different

              qDebug() << "MainWindow mapToGlobal" << this->mapToGlobal(QPoint(0,0));
              qDebug() << "MainWindow Pos" << this->pos();
          
          output:
          
          MainWindow mapToGlobal QPoint(6,60)
          MainWindow Pos QPoint(3,30)
          

          BTW I am using Qt 6.3.1

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB @mchinand last edited by

            @mchinand
            The point is that @gmat is showing values where in every case the Y coordinate == 10 x the X coordinate, which is pretty noticeable and odd... !

            M 1 Reply Last reply Reply Quote 0
            • M
              mchinand @JonB last edited by

              Right, I'd like to see what pos() shows in those cases when the mapToGlobal() is showing those crazy y values. His single example above shows reasonable values for both mapToGlobal() and pos() (depending on where the window actual is, I guess).

              1 Reply Last reply Reply Quote 1
              • G
                gmat last edited by

                Ah, so I went back to Qt 5.15.2 and it works as expected. Looks like they "introduced" a bug in 6.3.1.

                1 Reply Last reply Reply Quote 0
                • A
                  Asperamanca last edited by

                  This one?

                  1 Reply Last reply Reply Quote 0
                  • G
                    gmat last edited by gmat

                    @Asperamanca said in mapToGlobal, wrong values with Linux:

                    Yup that looks like it.

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