PDA

View Full Version : Can't create a correct child of qApp->activewindow



tonnot
31st March 2011, 19:41
I want to create an instance of a custom widget created 'onthefly' , and I dont want it was viewed at the task bar (Windows).

Because My class does not receive any Qwidget parent I use qApp->activeWindow())

QWidget *a=new QWidget(qApp->activeWindow());
a->setWindowFlags(Qt::Window);
a->show();

Ok, I see two applications into the taskbar
Any help ?

wysota
31st March 2011, 20:26
What does qApp->activeWindow() return at this moment?

tonnot
1st April 2011, 07:36
mmm I'm afraid that... nothing.
The app is not created because I use:


QApplication a(argc, argv);
MainWindow w;
w.show(); return a.exec();

Inside mainwindow contructor I have a code to create a new Qwidget-Window, but still I have no app.>actiwindow .....
Any help ? Can I force the creation of main app in some way ?
Thanks

wysota
1st April 2011, 09:39
You need to have an active window for activeWindow() to return something. An active window is a window which has the keyboard focus, apparently this is not the case for you.

tonnot
1st April 2011, 10:24
Yes I understand it.
My goal is to create a new window owned by the main and NOT showed at the taskbar (passing the proper QTflags and a parent)
I can do it if a window is already showed
Is there a way to do what I want or have I to wait until the mainwindow is showed ?
Thanks

wysota
1st April 2011, 10:29
You can pass a pointer to the other window.