QPixmap- It is not safe to use QPixmap outside the gui Thread
-
wrote on 6 Aug 2013, 08:44 last edited by
in main function my dialog is displayed
and i have created a new pthread as followspthread_t t1;
pthread_create(&t1,NULL,&message,NULL);void * message(void *)
{
// data for receiving the buffer on udp
//after receiving
dialog d; // my gui
d.display(buffer); // sending the received buffer to the gui function for displaying the values on the labels}
when i run this code am getting the following error
QPixmap- It is not safe to use QPixmap outside the gui Thread
i have not used QPixmap then why this error
am able to print the received data at the console but not able to set the text on the gui labelscan any one suggest why
}
`
-
Hi,
You are using GUI elements outside the GUI thread and that's not allowed. You'll have to send your buffer to your main thread and from there show your dialog.
Also, please enclose your code in coding tags (first icon to the right) so it's more readable :)
-
wrote on 6 Aug 2013, 10:14 last edited by
my main thread code is as follows
@
main.cpp
@int main()
{QApplication a;
Ground gs; // dialog name
gs.show();
return a.exec():
}
now my question how should i send it to main thread -
Signals and slots can safely transfer data across threads
1/4