5
votes

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

1

1 Answers

5
votes

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.