[Interest] QApplication.activeWindow().pos() not returning correct value after sacling on OSX

Scott Aron Bloom scott at towel42.com
Thu Feb 18 05:33:45 CET 2016


In the docs for QWidget::geometry() it says whats going on here..

http://doc.qt.io/qt-5/qwidget.html#geometry-prop


"This property holds the geometry of the widget relative to its parent and excluding the window frame."

It does NOT return a global position, if you want a global position, you must convert to the global via
http://doc.qt.io/qt-5/application-windows.html#window-geometry should be read to learn what geometry represents.

If you know the parent, you can use parent->mapToGlobal( QRect ) to find the global rectangle.


Scott




From: Interest [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Frank Rueter | OHUfx
Sent: Wednesday, February 17, 2016 19:21
To: Tony Rietwyk <tony at rightsoft.com.au>
Cc: interest at qt-project.org
Subject: Re: [Interest] QApplication.activeWindow().pos() not returning correct value after sacling on OSX

Hi Tony,

sorry, let me clarify:
QT's co-oridnate system starts at the top left, right?
So when I scale the window by dragging the left side (or the top), the point of origin changes and thus I expect a different global position for the widget.

The reason I am tying to determine the exact geometry of the parent application is because I am trying to implement something like an invisible slider, a mode where the use can click+drag anywhere in the host application to change a certain value. Upon release the mode disables itself until a hotkey is pressed again.
E.g. if the host application is a video player, I am trying to implement a mode where the user can hit a hotkey, then click&drag anywhere in the player to scrub through the video.

I'm sure there are better ways to go about this (and I'd love to hear advise on this), but at the moment, as a proof of concept, I am creating a transparent widget that catches the mouse event and emits the required signal, and I'd like for that widget to perfectly sit on top of the parent app so if the user click/drags outside of it, it won't have any effect.

Ideally I'd just force the mouse event to my QObject rather than create an transparent widget, but I don't know if this is possible?

Does that make sense?

Cheers,
frank

On 18/02/16 3:59 pm, Tony Rietwyk wrote:
Hi Frank,

I don't understand what you are asking!  Why do you expect that changing the window size will change the position?   You say 'resulting in an offset for my widget' - sounds like you are adding the new pos instead of just using it?

Tracking foreign native windows is pretty rare.  You need to provide a cut-down version of what you are doing so others can easily run it.

Regards,

Tony


From: Interest [mailto:interest-bounces+tony=rightsoft.com.au at qt-project.org] On Behalf Of Frank Rueter | OHUfx
Sent: Thursday, 18 February 2016 8:14 AM
To: interest at qt-project.org<mailto:interest at qt-project.org>
Subject: Re: [Interest] QApplication.activeWindow().pos() not returning correct value after sacling on OSX

anybody?
is this a bug?
On 16/02/16 12:21 pm, Frank Rueter | OHUfx wrote:
Hi,

I am trying to figure out my host application's window geometry reliably and am struggling a bit.

I use QApplication.activeWindow().geometry() to drive my custom widget's geometry (I need to sit exactly on top of the host application).
All works fine and my widget sits exactly on top of the host application window, until the host app is scaled by dragging one of it's sides out or in. After that QApplication.activeWindow().geometry() still returns the same exact position, though the size is correct, resulting in an offset for my widget.
Turns out scaling windows on OSX by dragging their edges doesn't seem to update QApplication.activeWindow().pos()

As soon as I grab the title bar and move the host app a tiny bit, QApplication.activeWindow().pos() seems to be updated correctly.

Is there a fix/workaround for this?

Cheers,
frank
--
[ohufxLogo 50x50]<http://www.ohufx.com>

vfx compositing<http://ohufx.com/index.php/vfx-compositing> | workflow customisation and consulting<http://ohufx.com/index.php/vfx-customising>






_______________________________________________

Interest mailing list

Interest at qt-project.org<mailto:Interest at qt-project.org>

http://lists.qt-project.org/mailman/listinfo/interest

--
[ohufxLogo 50x50]<http://www.ohufx.com>

vfx compositing<http://ohufx.com/index.php/vfx-compositing> | workflow customisation and consulting<http://ohufx.com/index.php/vfx-customising>



--
[ohufxLogo 50x50]<http://www.ohufx.com>

vfx compositing<http://ohufx.com/index.php/vfx-compositing> | workflow customisation and consulting<http://ohufx.com/index.php/vfx-customising>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160218/6157b564/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 2666 bytes
Desc: image001.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160218/6157b564/attachment.png>


More information about the Interest mailing list