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. Creating pthread in qt creator
Forum Updated to NodeBB v4.3 + New Features

Creating pthread in qt creator

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.2k 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.
  • P Offline
    P Offline
    pirpi
    wrote on 6 Nov 2014, 12:12 last edited by
    #1

    Hi all,
    I am a newbie, I just want to send some messages from pthreads thread function to qt GUI. I am creating thread like this
    pthread_create(&thread_read, NULL,&read_data,NULL);.
    But I am getting following error
    " read_data is not declared in this scope".
    I have added
    QMAKE_CXXFLAGS+= -std=gnu++0x -pthread -lpthread
    LIBS += -L/usr/include -pthread

    in .pro file in the project. Could anybody help me with this?

    Thanks
    pirpi

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Nov 2014, 12:29 last edited by
      #2

      Hi and welcome to devnet,

      Where is read_data located ?

      Also, since you are using Qt, why not take advantage of QThread which is cross-plaform ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pirpi
        wrote on 6 Nov 2014, 12:35 last edited by
        #3

        No, already I have done a program using posix thread. I just want to send some message from posix threads to qt gui. For that purpose I just want to use posix thread.

        read_data is located in main.cpp. I am defining read_data like this

        void *read_data()
        {
        cout<<"Hello"<<endl;
        }

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 6 Nov 2014, 23:22 last edited by
          #4

          And where do you create the pthread ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pirpi
            wrote on 7 Nov 2014, 03:54 last edited by
            #5

            I have created pthread in main(). I am creating like this
            pthread_create(&thread_read, NULL,&read_data,NULL); and I am defining read_data in the same main.cpp like this void * read_data().
            Could you please help me with this.

            Thanks
            pirpi

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 8 Nov 2014, 00:23 last edited by
              #6

              Can you show your complete code ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              1/6

              6 Nov 2014, 12:12

              • Login

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