Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QWidget::mapToGlobal() when the widget is not visible

Tags:

qt

qwidget

can QWidget::mapToGlobal work when the widget is not visible ? I dont find anything on the manual . If it cannot Why ?

like image 921
Neel Basu Avatar asked Sep 13 '11 19:09

Neel Basu


1 Answers

I've just written a small program that calls QWidget::mapToGlobal( QPoint( 0,0 ) ) on a hidden widget. What I found was that the position I got varied, depending on whether the widget had already been displayed on screen before I queried its position.

The QWidget::mapToGlobal() documentation says:

Translates the widget coordinate pos to global screen coordinates. For example, mapToGlobal(QPoint(0,0)) would give the global coordinates of the top-left pixel of the widget.

Reading that, it does seem logical that if the widget is not visible, it cannot possibly have a guaranteed global position on the screen.

The actual result you get from calling the method seems to depend on the position the widget was last displayed at, if any. So it seems unwise to depend on this behaviour being stable across current or future versions of Qt.

like image 182
Clare Macrae Avatar answered Oct 31 '22 17:10

Clare Macrae