I have 2 threads. One main thread and one created thread. I'm creating thread in constructor of class and pass it "this" pointer. In a thread I'm accessing to class via pointer and call a public method (function) of this class. In this method I'm calling setText method in QLabel widget. It does not work. Program is crashed. When I use setText in another method of this class it works. I've tried another methods of QLabel and some works, and some doesn't. Any method who has "set" in its name doesn't work, and clear too, but methods like adjustSize() works. I tried another widgets and problem is same.

I've created thread with winapi CreateThread function, and name of class is MainWin.

Code of created thread:

DWORD WINAPI ItemReceiver(LPVOID param)
{
MainWin *mwin = (MainWin*)param;
while(true)
{
WaitForSingleObject(SEM,INFINITE);
mwin->ReceiveItem();
}

return 0;
}

Way of calling setText function:

lblCommand->setText("Command: ");

lblCommand is pointer to QLabel.