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

Frank Rueter | OHUfx frank at ohufx.com
Thu Feb 18 07:34:38 CET 2016


Thanks again, Tony, this works perfectly for me now.

On 18/02/16 4:59 pm, Tony Rietwyk wrote:
>
> Hi Frank - sorry for replying to you directly before!
>
> Have you looked at event filtering?  A derived QObject can monitor, 
> and supress events going to another QObject - including windows.  So:
>
> - when the hot key occurs, you installEventFilter on the current window,
>
> - if KeyPress Esc, then cancel,
>
> - if MousePress, then record start pos,
>
> - if MouseMove, then record the end pos
>
> - if MouseRelease, then record the end pos and finish
>
> When you finish or cancel, removeEventFilter.  While active, you 
> always suppress the event to stop if going to the target window.
>
> Hope that helps,
>
> Tony
>
> *From:*Frank Rueter | OHUfx [mailto:frank at ohufx.com]
> *Sent:* Thursday, 18 February 2016 2:21 PM
> *To:* Tony Rietwyk
> *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> *
>
>
>
> _______________________________________________
> Interest mailing list
> 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>* *

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


More information about the Interest mailing list