Creating pthread in qt creator
-
wrote on 6 Nov 2014, 12:12 last edited by
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 -pthreadin .pro file in the project. Could anybody help me with this?
Thanks
pirpi -
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 ?
-
wrote on 6 Nov 2014, 12:35 last edited by
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;
} -
And where do you create the pthread ?
-
wrote on 7 Nov 2014, 03:54 last edited by
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 -
Can you show your complete code ?
1/6