Results 1 to 3 of 3

Thread: Problem with event handling of multiple windows

  1. #1
    Join Date
    Feb 2014
    Posts
    26
    Qt products
    Qt5
    Platforms
    Windows

    Default Problem with event handling of multiple windows

    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,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with event handling of multiple windows

    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.

  3. #3
    Join Date
    Feb 2014
    Posts
    26
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with event handling of multiple windows

    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.

Similar Threads

  1. about multiple windows design problem
    By kenchan in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2012, 04:44
  2. Replies: 1
    Last Post: 14th June 2011, 03:46
  3. Subclassed qlistwidget event handling problem
    By Annihilator in forum Qt Programming
    Replies: 9
    Last Post: 13th February 2010, 18:55
  4. event handling...
    By xyzt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2008, 07:16
  5. Event handling problem
    By Mel Seyle in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2007, 04:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.