[Interest] Find frontmost widget of specific type?

John Weeks john at wavemetrics.com
Mon Oct 22 22:37:36 CEST 2018


We faced pretty much exactly this issue when we ported our very large application to Qt, starting with Qt 4.8. We have many places where we expect to be able to walk a window list in Z order. I wound up using Activate/Deactivate events to keep the list myself. I can't really recommend it- it has been pretty much of a nightmare to make it robust and bug-free, especially as Qt has a couple of bugs in their own notion of window activation. You can't really use the debugger to debug these issues, as the activation of the debugger changes the activation of the application's windows.

I have made it work pretty well, but I quake in my boots whenever I get a bug report about window order.

We are now using Qt 5.9 and don't have any sort of replacement for my delicate and difficult code.

-John Weeks
WaveMetrics, Inc.

> On Oct 22, 2018, at 11:37 AM, Israel Brewster <ibrewster at flyravn.com> wrote:
> 
> I have an application (Qt 5.9) that has a variety of different types of windows you can open. If a user selects to open a type of window that is already open, I want to position the new  window relative to the existing one. I can easily find any existing windows of a given type by going through the list of widgets in QApplication::allWidgets(), doing a qobject_cast to the proper type, and checking the result, but is there a way to determine which of these is the frontmost of that type? QApplication::ActiveWindow() doesn't help, because the activeWindow may not be of that type.
> 
> -----------------------------------------------
> Israel Brewster
> Systems Analyst II
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7293
> -----------------------------------------------
> 
> <image001.jpg>
> 
>   
> 
> <image002.jpg>
> 
> 
> 
> 
>   
> 
> 
> <Israel Brewster.vcf>_______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list