Results 1 to 3 of 3

Thread: Multiple threads in a single class

  1. #1
    Join Date
    Feb 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Multiple threads in a single class

    Hi,

    I want to write a QObject derived class which should contain two threads. Each thread should run a different function of my class (endless loops).

    I am confused which is the right and easiest way (subclassing QThread, using QThread directly, movetothread(), QtConcurrent:run).

    Can someone give me a smal example?

    Best regards,

    Matthias

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

    Default Re: Multiple threads in a single class

    If you really need an endless loop then subclassing QThread and reimplementing run() is the way to go. But it might be that you only think you need an endless loop in which case other approaches are viable as well.
    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.


  3. #3
    Join Date
    Aug 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple threads in a single class

    Its all about coherence. If you want multiple classes to do your job, running multiple threads for it, make sure that each and every class is coherent enough otherwise you've minimized reuse........

Similar Threads

  1. Replies: 1
    Last Post: 13th April 2011, 23:08
  2. multiple table in a single variable
    By sattu in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2011, 11:01
  3. Should I use multiple or a single model(s)?
    By Cotlone in forum Newbie
    Replies: 2
    Last Post: 7th May 2010, 03:39
  4. Single QGLContext across multiple QGLWidgets
    By pseudosig in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2008, 23:13
  5. Replies: 11
    Last Post: 7th July 2006, 13:09

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.