PDA

View Full Version : QMainWindow created after qApp->exec() doesn't show up



vardhan
21st November 2007, 09:58
Just working on my first Qt ( qt4.2.3 / WinXP /GPL ) application.
I've a systray icon, with 'new' , which will bring a new top level window.

The problem is, this new QMainWindow is not visible. However when i
exit, i see a flickr , so the window was created ..
If I call my create function before qApp->exec(), the windows are create fine.

What additional step is needed to get newly create QMainWindow into the
list of top level windows ?


The relevant code snippets:
===============================
class Top : public QMainWindow
{
Q_OBJECT
public:
Top() {
QTextEdit * textEdit = new QTextEdit;
setCentralWidget(textEdit);
}
};
================================
public slots:
void actionNew() {
Top * t = new Top();
//t->showFullScreen();
t->activateWindow();
t->raise();
t->repaint();
t->show();
}
================================

--Regards
---Vardhan

jpn
21st November 2007, 10:16
What does main() look like?

vardhan
21st November 2007, 10:40
my main() is standard:

======
int
main(int Argc, char **Argv)
{
Q_INIT_RESOURCE(term);
QApplication a (Argc,Argv);

app.startup();
app.actionNew();
app.actionNew();


return a.exec();
}
=============

'app.startup() create system tray with menu item which calls 'actionNew().
The two top level created before a.exec() are visible, where the one create from 'new' are not.


newAction = new QAction(tr("&New"), this);
connect(quitAction, SIGNAL(triggered()), this, SLOT(actionNew()));


--Regards
---Vardhan

jpn
21st November 2007, 10:45
Notice that you connect quitAction to SLOT(actionNew()).

vardhan
21st November 2007, 10:50
Oh thanx ,, cut-n-paste problem (-:


--regards
----vardhan

vardhan
21st November 2007, 10:51
And the flashing of window at exit should have given a clue (-: