[Qt-interest] obtaining application window from QApplication instance

Girish Ramakrishnan girish at forwardbias.in
Fri Nov 12 18:14:22 CET 2010


Hi Giacomo,
If you have only one application window just store that instance in a global
variable (just like qApp) or if you don't like that provide a
MainWindow::instance() that provides the MainWindow instance.

topLevelWidgets returns all sorts of windows - even those that are internal
to Qt too. You can run through the list and qobject_cast<MainWindow *>.

There is no other way.

Girish

On Fri, Nov 12, 2010 at 2:58 PM, Giacomo S. <
giacomo.strangolino at elettra.trieste.it> wrote:

> Hi to all.
>
> I would like to know how to retrieve the application window (if
> possible) from the QApplication instance.
>
> tried with topLevelWidgets() but in the case of a QMainWindow also
> toolbar menus and actions are returned, which is not what I want...
>
> what I need to do is to raise the window of a running application when a
> particular message is received through dbus, in order to make it appear
> on the desktop when it is iconified or below other windows.
>
> Thanks in advance.
>
> Giacomo
>
> Elettra - Synchrotron Radiation Facility
>
> Trieste, Italy.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101112/9375708f/attachment.html 


More information about the Qt-interest-old mailing list