Results 1 to 16 of 16

Thread: whatś the better in Threads

  1. #1
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default whatś the better in Threads

    Hello all
    can you gimme an opinion? Whats the better to make some threads and use signal/slots?
    Qthreads, QtConcurrent, QRunnable, another one...
    Thanks everyone

  2. #2
    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: whatś the better in Threads

    all the options you suggested are good.
    No, they are great!

    It depends what for though, which you didn't mention.

    Can you tell me what is better - a hammer or a screw driver?
    ==========================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.

  3. #3
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatś the better in Threads

    youŕe right xD
    I'am asking it cause i am trying use the signal/slot with QRunnable, but when i put the Q_OBJECT macro, i get a "undefined reference to vtable". As i searched, this error occurs when a virtual method is missing, but i didnt create any virtual method and the run() is ok.
    Any idea friend?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatś the better in Threads

    QRunnable doesn't inherit QObject.
    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.


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

    Tio (25th May 2010)

  6. #5
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatś the better in Threads

    Wysota
    So, there's no way, right?

  7. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: whatś the better in Threads

    MOC uses vtable, maybe you forgot to run that (and added newly built files) after you added Q_OBJECT macro.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatś the better in Threads

    Quote Originally Posted by Tio View Post
    So, there's no way, right?
    Did you inherit QObject?
    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
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatś the better in Threads

    Wysota
    No, i ve just made the class inherit from QRunnable.

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatś the better in Threads

    Quote Originally Posted by Tio View Post
    No, i ve just made the class inherit from QRunnable.
    What is the base class required to use signals or slots in a class?
    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. #10
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatś the better in Threads

    QObject, i guess?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatś the better in Threads

    Quote Originally Posted by Tio View Post
    QObject, i guess?
    Add the two facts together and you will have your solution.
    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.


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

    Tio (26th May 2010)

  14. #12
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatś the better in Threads

    ok wysota, thanks
    my conclusion is: use QThreads xD
    hugs people, thanks a lot

  15. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatś the better in Threads

    You could have just subclassed both QObject and QRunnable at the same time...
    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.


  16. #14
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatÅ› the better in Threads

    i´ve tried it wysota, but the problem persist...it´s a problem when there is a noob like me xD

    class Thread : public QRunnable, QObject , in header file
    Thread::Thread(QString strCaminhoOff, QString strCaminhoPP) : QRunnable , in constructor

    Maybe is missing inherit QObject in constructor, but the QT creator dont let me put it there...

    In other hand, the aplication in QThread is fine, for now xD

    ps: in time -> which tag i choose up there to my text appears like a QT code? =P

  17. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: whatÅ› the better in Threads

    Quote Originally Posted by Tio View Post
    i´ve tried it wysota, but the problem persist...it´s a problem when there is a noob like me xD

    Qt Code:
    1. class Thread : public QRunnable, QObject
    To copy to clipboard, switch view to plain text mode 
    , in header file
    Qt Code:
    1. Thread::Thread(QString strCaminhoOff, QString strCaminhoPP) : QRunnable
    To copy to clipboard, switch view to plain text mode 
    , in constructor
    QObject has to come first in inheritance tree. And both classes need to be inherited publically.

    In other hand, the aplication in QThread is fine, for now xD
    That's ok, it's probably a better solution than using QRunnable in this case.
    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.


  18. #16
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: whatÅ› the better in Threads

    yeah, i think so...thanks for all help friend.
    c ya

Similar Threads

  1. Threads in Qt
    By freekill in forum Qt Programming
    Replies: 4
    Last Post: 11th November 2009, 18:49
  2. Qt threads
    By ^Nisok^ in forum Newbie
    Replies: 12
    Last Post: 22nd April 2009, 14:35
  3. Threads...
    By Abc in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2008, 17:35
  4. threads and socket
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 10th April 2008, 15:34
  5. Once more: Threads in Qt4
    By high_flyer in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2006, 18:35

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.