Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pthread w/ class in QT
Forum Updated to NodeBB v4.3 + New Features

pthread w/ class in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jackyPITCHJ Offline
    jackyPITCHJ Offline
    jackyPITCH
    wrote on last edited by
    #1

    Hello ! : )

    I'm making a qt program which need to be able to run 2 method of 2 differents class at the same time. I already made it run with the method declared in the main() and it works, but i need to make it run with the 2 methods from different classes, with pthread.h . I'm stuck ! Need help , thanks : )

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      it must be pthreads?
      If something very light, u could use a QTimer.
      else, this might be helpful
      https://computing.llnl.gov/tutorials/pthreads/

      jackyPITCHJ 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        it must be pthreads?
        If something very light, u could use a QTimer.
        else, this might be helpful
        https://computing.llnl.gov/tutorials/pthreads/

        jackyPITCHJ Offline
        jackyPITCHJ Offline
        jackyPITCH
        wrote on last edited by
        #3

        @mrjj No it mustn't be pthreads but its too heavy to use a Qtimer, any suggestions ? The link you gave does not help me to use pthread with class, unless i have made a bad reading but thanks : )

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @jackyPITCH said:
          pthread
          is not based on classes, its a c api.
          But nothing wrong calling some class function from the thread.
          Since its C it dont accept a class for callback directly.

          however, Qt has it own thread handling
          http://doc.qt.io/qt-5/thread-basics.html
          with many examples
          http://doc.qt.io/qt-5/examples-threadandconcurrent.html

          So maybe thats an options?

          1 Reply Last reply
          0
          • jackyPITCHJ Offline
            jackyPITCHJ Offline
            jackyPITCH
            wrote on last edited by
            #5

            @mrjj i'm using qt4, does this work?

            mrjjM 1 Reply Last reply
            0
            • jackyPITCHJ jackyPITCH

              @mrjj i'm using qt4, does this work?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jackyPITCH
              hi, i think so
              http://doc.qt.io/qt-4.8/threads.html

              also , should be quick to test out using
              https://fabienpn.wordpress.com/2013/05/01/qt-thread-simple-and-stable-with-sources/

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved