Qt-interest Archive, November 2006
Does QApplication give special recognition to its first window?
Message 1 in thread
Does QApplication give special recognition to the first window? For example,
when I start a program, I typically create a QMainWindow in the function
main() just before I call QApplication::exec(). Does that window hold a
special status for the QApplication instance? Can I ask for the "main
window" of an application?
Steven
--
[ signature omitted ]
Message 2 in thread
On 11/12/06, Steven T. Hatton <hattons@xxxxxxxxxxxxxxxxxx> wrote:
> Does QApplication give special recognition to the first window? For example,
> when I start a program, I typically create a QMainWindow in the function
> main() just before I call QApplication::exec(). Does that window hold a
> special status for the QApplication instance? Can I ask for the "main
> window" of an application?
No, there is no such thing. All windows are equal :) There is a
however "QApplication::setMainWidget", but you have to set it
manually, and it only thing it means, is that QApplication will exit
when this widget is destroyed.
--
[ signature omitted ]
Message 3 in thread
On 12.11.06 11:42:20, Steven T. Hatton wrote:
> Does QApplication give special recognition to the first window?
In General no.
> For example,
> when I start a program, I typically create a QMainWindow in the function
> main() just before I call QApplication::exec(). Does that window hold a
> special status for the QApplication instance?
If you do exactly like that: No. In Qt3 there's a main widget in a
QApplication, which you have to explicitly set after the widget
creation.
> Can I ask for the "main window" of an application?
Yes, in Qt3 you can make it the main widget. In Qt4 you could use a
public static member function in your Mainwindow class to return the
mainwindow instance. Setting this would be done during the construction.
Unfortunately I can't remember the pattern name for this, so you could
more easily search the web for more information...
Andreas
--
[ signature omitted ]