abhinandh
abhinandh

Reputation: 103

How to find the global screen position of a Qt app?

I need the global screen position of a Qt widget for which I need the application's global position. How can this be found?

Thanks.

Upvotes: 10

Views: 16168

Answers (4)

Harish P J
Harish P J

Reputation: 41

widget->mapToGlobal(QPoint(0,0))

Upvotes: 2

Jruv
Jruv

Reputation: 1598

widget->parentWidget().mapToGlobal( widget->pos() )

Upvotes: 1

Frank Osterfeld
Frank Osterfeld

Reputation: 25165

widget->mapToGlobal( widget->pos() )

Upvotes: 14

Alex Martelli
Alex Martelli

Reputation: 882851

You want the pos property of your top-level window:

This property holds the position of the widget within its parent widget.

If the widget is a window, the position is that of the widget on the desktop, including its frame.

Be sure to also check this part of the Qt docs for details.

Upvotes: 2

Related Questions