PDA

View Full Version : Problem with event handling of multiple windows



rakefet
9th April 2014, 16:08
Hi,

I have a win32 application that displays a 32win window. This window's handler is hwin1. This window launchs a dialog( NOT Qdialog). the dialog's handler is hdlg. This dialog has multiple events. One of the event is refreshing hwin1. The other is launching a QDialog. My code to launch the QDialog is:

QApplication *a;
a = new QApplication(0, 0);
QWinWidget win(hDlg);
MyDialog *w = new MyDialog(&win);
ok = w->exec();


In my dialog I have an exit button and an action button. In the action button I am doing several actions that effects the display of hwin1. So in the end of the actions I am calling the function that send the message to the win32 window to refresh hwin1.

My problem is the display is refreshing only when I pushed the exit button of my Qdialog.
Also, as you can see from my code I don't have the a-<exec() command because I was thinking that the only events I have are the events of my QDialog and the rest of the events are handled by the win32 main window.

Do you think I am doing it right?

Thank you,

d_stranz
10th April 2014, 02:28
Do you think I am doing it right?

No. The application owns the Qt event loop so if it isn't started (by QApplication::exec()) then nothing happens.

rakefet
11th April 2014, 21:40
Thanks. I replaced my code from w->exec() to w->show() and to a.exec() but still the main window was not updated until I closed my Qdialog.
The solution was that I created a new thread in my program and in this thread I generated my Qdialog. This way I was able to refresh the main window while my QDialog was up. Another problem I was facing in this setup. Every time I closed a message box in QDialog, the QDialog was closed also. This was solved when I went back and replaced w->exec() to w->show() and removed a.exec(). I am not sure why.