Results 1 to 2 of 2

Thread: porting from wxwidgets & need event help

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question porting from wxwidgets & need event help

    I am porting the gui of an app from wxwidgets to Qt. It's fairly large and I want to do as little disruption as possible. One thing that I am not sure how to handle is that other threads call the main (ui) thread and ask it to do functions using:

    Qt Code:
    1. void async_ui_thread_task(const boost::function<void()>& f) {
    2. wxCommandEvent event(wxEVT_EVAL);
    3. event.SetClientData(new boost::function<void ()>(f));
    4. wxGetApp().AddPendingEvent(event);
    5. }
    To copy to clipboard, switch view to plain text mode 

    I am trying to find an equivalent Qt way to do this. I cannot convert the existing thread types to QtThreads. I've looked at QApplication/QCoreApplication and the only thing I can think of is to create my own events and put the functions in these events. The problem is how do I get the right receiver to process them (assuming that I use QCoreApplication:: postEvent). Some do not belong to objects and some are private functions (I can make them public if that is what it takes).

    Has anyone had any experience with this?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: porting from wxwidgets & need event help

    You can post them to the application object and then reimplement the application's customEvent() method where you will distribute the tasks as you want them. Just make sure to allocate events on heap if you use postEvent().

  3. The following user says thank you to wysota for this useful post:

    ntp (12th December 2008)

Similar Threads

  1. Event propagation direction
    By spraff in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2008, 21:03
  2. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  3. Replies: 1
    Last Post: 16th October 2007, 22:41
  4. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.