Results 1 to 4 of 4

Thread: Background threads running in Qt Application.

  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Question Background threads running in Qt Application.

    I execute the code below

    Qt Code:
    1. #include <QApplication>
    2.  
    3. int main (int argc, char** argv)
    4. {
    5. QApplication app(argc, argv);
    6. app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    and see the process on Windows Task Manager (WTM).

    The WTM shows 7 threads for this application.

    I read that Qt does not create any thread in the background then
    why does it get reflected on WTM.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Background threads running in Qt Application.

    That application produces exactly one thread on Windows XP and Windows 7 here. Since you have not given it a UI and there's no obvious way to exit it perhaps you are looking at multiple instances. Alternatively, perhaps you have use Microsoft's compiler and its runtime is doing something odd with threads.

    WinXPDev.png
    Win7_32.jpg

    Some of the networking functions have recently been implemented with an internal worker thread, so it is not true that Qt apps are completely thread-free.

  3. #3
    Join Date
    Jun 2012
    Posts
    3

    Default Re: Background threads running in Qt Application.

    I am using 4.6.3 version of Qt and mingw32-make compiler on Windows 7 where the test app shows 7 threads.

    I built the test app on Linux using Qt 4.8.1 and there it shows only one thread.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Background threads running in Qt Application.

    My earlier counter-examples were built with 4.8.0. So I went back to 4.6.2 (I didn't have a 4.6.3 available) and, not surprisingly, there is precisely one thread on Win XP, Win 7 64-bit and Win 7 32-bit. I do not know what you are doing or why you should care in any case.

    Win7_32.png Win7Test_64.png

Similar Threads

  1. Terminating Multiple Running Threads?
    By PLan2010 in forum Newbie
    Replies: 2
    Last Post: 22nd February 2011, 00:15
  2. Replies: 4
    Last Post: 11th January 2011, 08:56
  3. Replies: 0
    Last Post: 15th April 2010, 14:44
  4. Running my app in the background
    By srohit24 in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2009, 00:15
  5. How to redraw QGraphicsScene background in running
    By wisconxing in forum Qt Programming
    Replies: 3
    Last Post: 17th November 2008, 14:10

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.