mapToGlobal, wrong values with Linux
-
wrote on 9 Aug 2022, 19:51 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 ?
-
wrote on 10 Aug 2022, 19:44 last edited by
What is the value of
this->pos()
at the same time you callmapToGlobal(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. -
wrote on 11 Aug 2022, 14:05 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
-
What is the value of
this->pos()
at the same time you callmapToGlobal(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. -
wrote on 11 Aug 2022, 14:14 last edited by
Right, I'd like to see what
pos()
shows in those cases when themapToGlobal()
is showing those crazy y values. His single example above shows reasonable values for bothmapToGlobal()
andpos()
(depending on where the window actual is, I guess). -
wrote on 11 Aug 2022, 14:53 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.
-
wrote on 31 Aug 2022, 19:02 last edited by
-
wrote on 19 Sept 2022, 13:08 last edited by gmat
@Asperamanca said in mapToGlobal, wrong values with Linux:
Yup that looks like it.