Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. mapToGlobal, wrong values with Linux
QtWS25 Last Chance

mapToGlobal, wrong values with Linux

Scheduled Pinned Locked Moved Unsolved Qt 6
maptogloballinuxubuntu6.3.1bad
8 Posts 4 Posters 1.3k Views
  • 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 Offline
    G Offline
    gmat
    wrote on 9 Aug 2022, 19:51 last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mchinand
      wrote on 10 Aug 2022, 19:44 last edited by
      #2

      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.

      J 1 Reply Last reply 11 Aug 2022, 14:11
      0
      • G Offline
        G Offline
        gmat
        wrote on 11 Aug 2022, 14:05 last edited by
        #3

        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
        0
        • M mchinand
          10 Aug 2022, 19:44

          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.

          J Online
          J Online
          JonB
          wrote on 11 Aug 2022, 14:11 last edited by
          #4

          @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 11 Aug 2022, 14:14
          0
          • J JonB
            11 Aug 2022, 14:11

            @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 Offline
            M Offline
            mchinand
            wrote on 11 Aug 2022, 14:14 last edited by
            #5

            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
            1
            • G Offline
              G Offline
              gmat
              wrote on 11 Aug 2022, 14:53 last edited by
              #6

              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
              0
              • A Offline
                A Offline
                Asperamanca
                wrote on 31 Aug 2022, 19:02 last edited by
                #7

                This one?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  gmat
                  wrote on 19 Sept 2022, 13:08 last edited by gmat
                  #8

                  @Asperamanca said in mapToGlobal, wrong values with Linux:

                  Yup that looks like it.

                  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