Results 1 to 9 of 9

Thread: using QThread without QApplication for a library ?

  1. #1
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question using QThread without QApplication for a library ?

    Hi,

    I'm working on a library, this one canbe used with or without QT. So, I would like to use QThread features but without QApplication or at least find a way to create a DLL that is not bound to QT.

    Thanks

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: using QThread without QApplication for a library ?

    If you use QThread you are "bound" with Qt

    You can for example use boost threads multi-platform thread library.

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

    pl01 (9th November 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using QThread without QApplication for a library ?

    Thanks,

    The problem is that I'm working on a C++ library... not a complete application !

    Now, my library use boost 1.44. I'm currently porting my library from VS2008 to QT creator.

    The problem is that I'm unable to build boost 1.44 for mingw and use it in QTCreator... see this post : http://www.qtcentre.org/threads/3584...d-boost-for-QT

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: using QThread without QApplication for a library ?

    The problem is that I'm working on a C++ library... not a complete application !
    What Zlatomir said still applies.

    You can't use Qt object without linking to Qt.
    You can use external sources such as boost, (if/when you succeed in building it) or just normal ptherads - this should be in the libpthread (POSIX theads) MinGW is shipped with, or you can implement your own Thread classes (but I would not recommend that).
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #5
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using QThread without QApplication for a library ?

    There is no problem to be "linked" statically in QT :-P

    But I don't need a QT Application... by example my library is used with Java or C# !!! So, I just need :
    1 - Create a DLL with QT embeded in it
    2 - Avoid the use of QApplication because it is not an application

    Not sure it is possible !

  7. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: using QThread without QApplication for a library ?

    Disclaimer: i'm no expert, but i don't see a connection between QApplication and QThread, so you should be able to create and use QThreads in a dll.

    If you use LGPL license for Qt, you might have some LGPL restrictions about static linking (as far as i know you must share your source too) so consult a lawyer if you decide to go that way.

  8. #7
    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: using QThread without QApplication for a library ?

    Quote Originally Posted by pl01 View Post
    But I don't need a QT Application... by example my library is used with Java or C# !!! So, I just need :
    1 - Create a DLL with QT embeded in it
    2 - Avoid the use of QApplication because it is not an application
    In short - use QApplication (or QCoreApplication, to be more precise). If the word "application" stings your eyes, you can always write this line:
    Qt Code:
    1. typedef QCoreApplication QLolipop;
    To copy to clipboard, switch view to plain text mode 
    and use QLolipop instead of QCoreApplication. It surely won't make your code become sweet and sticky. I would worry more about how you intend to run the event loop of your "not application".
    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.


  9. #8
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: using QThread without QApplication for a library ?

    Thanks,

    But I don't need any event loop !!!! I just need a portable threading library !

  10. #9
    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: using QThread without QApplication for a library ?

    Quote Originally Posted by pl01 View Post
    But I don't need any event loop !!!!
    If you don't need an event loop then you don't need an application object. And most probably you don't need any QThread objects as well. Just be aware most of Qt things require an event loop to work. Without it I think using Qt just for the QThread object is an overkill and it's much better to use boost or some other similar library.
    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.


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

    pl01 (10th November 2010)

Similar Threads

  1. QThread::exec and QApplication instantiation
    By Ray Froehlich in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2010, 05:35
  2. Replies: 4
    Last Post: 18th December 2009, 18:55
  3. QThread in a library
    By nimsnx in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2009, 16:09
  4. Replies: 4
    Last Post: 26th June 2008, 18:41
  5. <QtGui/QApplication> vs. <QApplication>
    By seneca in forum Qt Programming
    Replies: 5
    Last Post: 25th January 2006, 10:58

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.