Results 1 to 14 of 14

Thread: API Development - QEventLoop: Cannot be used without QApplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: API Development - QEventLoop: Cannot be used without QApplication

    Quote Originally Posted by d_stranz View Post
    I started to reply to this early on (would have been the first reply, in fact), then bailed when I could not think of a way in DllMain() (or whatever the equivalent is here) to get the event loop started without hanging on the exec() call. After reading all this, I still can't think of a way.
    The proper approach is to implement an event loop integration -- either process events of your other toolkit as part of Qt's event loop or process Qt events as part of the other framework's event loop. Qt already integrates quite well with glib's event loop, there is no reason one wouldn't integrate it with other event loops too.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,328
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: API Development - QEventLoop: Cannot be used without QApplication

    Qt already integrates quite well with glib's event loop
    Google is not being my friend tonight. Do you have a link to somewhere that discusses how this (or integration with any external event loop) is done (and not just someone blogging about having done it in less than 600 lines of code without sharing the details)?

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

    Default Re: API Development - QEventLoop: Cannot be used without QApplication

    First there is docs on QAbstractEventDispatcher which is a direct way to do the integration. Second there is or used to be the Qt-Mfc migration framework which I think integrated the two event loops. This there is Qt source code which has a number of event dispatchers implemented. Fourth a basic integration can be done by simply setting a timer in one of the frameworks and processing events of the other framework in the timeout function. I remember a couple of years ago I was using some CORBA framework with Qt and there was integration available for it that I think used the last approach. If I remember correctly it was a Qt Solution so there is a good chance its code is available somewhere on Qt's gitorious. But I think the glib one which Qt uses by default on Unix platforms if glib is available will give you the most information how to implement such integration.
    Last edited by wysota; 19th February 2015 at 23:21. Reason: spelling corrections
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    d_stranz (18th February 2015)

  5. #4
    Join Date
    Feb 2015
    Posts
    5
    Qt products
    Qt5

    Default Re: API Development - QEventLoop: Cannot be used without QApplication

    I finally have gotten this working.

    I had 2 separate problems both related to QCoreApplication not being present in the dll
    1. The dll threads weren't being spawned
    2. Signals from the threads back to the main thread were not occurring

    Both 1 & 2 were occurring due to lack of an event loop in the main thread.

    To fix one #1 followed the instruction here:
    ​http://stackoverflow.com/questions/2...qt-application

    To fix #2 I had to change my signal/slot connections
    Original code
    connect(commMGR, SIGNAL(collectFin()), this, SLOT(ReportCollectFin()));

    New and Working code
    connect(commMGR, SIGNAL(collectFin()), this, SLOT(ReportCollectFin()), Qt:irectConnection);
    commMGR->moveToThread(QAppPriv:Thread );

    where QAppPriv:Thread is the thread I created to solve problem #1.

    The elegant thing about my solution is that the newly added code is isolated from the original code so there is no way that the new code could introduce a bug in the original code which would necessitate retesting the entire dll.

    Thanks for helping me out

    - All

Similar Threads

  1. Problems with QEventLoop
    By marnando in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 25th February 2014, 19:19
  2. Replies: 4
    Last Post: 30th July 2013, 10:33
  3. QEventLoop not closing
    By kuku83 in forum Qt Programming
    Replies: 4
    Last Post: 10th April 2013, 16:01
  4. QEventLoop in QApplication
    By Qiieha in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2012, 19:08
  5. How to use QEventLoop?
    By MorrisLiang in forum Newbie
    Replies: 3
    Last Post: 13th May 2010, 16:23

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.