Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand your question correctly, you have code written for Boost.Asio . You would like to use that code inside a GUI application.</p> <p>What is not clear in your question is if you want to wrap the Qt/Gtk network layers through asynio for your code to work, if you are just looking for a solution for having both a gui event loop and asynio together.</p> <p>I will assume the second case.</p> <p>Both Qt and Gtk have methods to integrate foreign events in their event loop. See for example <a href="http://developer.kde.org/documentation/tutorials/qtgtk/main.html" rel="nofollow noreferrer">qtgtk</a> where the Qt event loop is plugged into Gtk.</p> <p>In the specific case of Qt, if you want to generate events for Qt, you can use the following class: <a href="http://qt-project.org/doc/qt-5/qabstracteventdispatcher.html" rel="nofollow noreferrer">QAbstractEventDispatcher</a>.</p> <p>After a quick look at boost asio, I think you need to do the following:</p> <ul> <li>have a recurring QTimer with duration zero that calls io_service::run() all the time. That way, boost::asio will call your completion handler as soon as your asynchronous operation is completed.</li> <li>in your completion handler, two options: <ul> <li>if your completion operation is a long one, separated from the GUI, do your business and make sure to call qApp.processEvents() regularly to keep the GUI responsive</li> <li>if you just want to communicate back with the gui: <ol> <li>define a custom <a href="http://qt-project.org/doc/qt-5/qevent.html" rel="nofollow noreferrer">QEvent</a> type</li> <li><a href="http://qt-project.org/doc/qt-5/qwidget.html#event" rel="nofollow noreferrer">subscribe to this event</a></li> <li>post your event to Qt event loop using <a href="http://qt-project.org/doc/qt-5/qcoreapplication.html#postEvent" rel="nofollow noreferrer">QCoreApplication::postEvent()</a>.</li> </ol></li> </ul></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload