ntp
12th December 2008, 02:35
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:
void async_ui_thread_task(const boost::function<void()>& f) {
wxCommandEvent event(wxEVT_EVAL);
event.SetClientData(new boost::function<void ()>(f));
wxGetApp().AddPendingEvent(event);
}
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?
void async_ui_thread_task(const boost::function<void()>& f) {
wxCommandEvent event(wxEVT_EVAL);
event.SetClientData(new boost::function<void ()>(f));
wxGetApp().AddPendingEvent(event);
}
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?