This is a QT application. I've used winapi because it's similar to me. I've never used QThread, but I will try.
Thanks
This is a QT application. I've used winapi because it's similar to me. I've never used QThread, but I will try.
Thanks
"wysota: You can't access QObject subclasses from within a worker thread."
Sometimes I can:
lblCommand->adjustSize(); //pass
lblCommand->childAt(20,20); //pass
lblCommand->setVisible(true); //crash
In other words, you MUST NOT touch GUI from a worker thread.
QObject Reentrancy:
Although QObject is reentrant, the GUI classes, notably QWidget and all its subclasses, are not reentrant. They can only be used from the main thread. As noted earlier, QCoreApplication::exec() must also be called from that thread.
In practice, the impossibility of using GUI classes in other threads than the main thread can easily be worked around by putting time-consuming operations in a separate worker thread and displaying the results on screen in the main thread when the worker thread is finished. This is the approach used for implementing the Mandelbrot and the Blocking Fortune Client example.
J-P Nurmi
Try running those in a loop and do something else with the GUI in between (like move the window with your mouse). While childAt() might suceed as it doesn't touch much of the structures, adjustSize() is bound to fail eventually. setVisible() is an obvious candidate for an immediate crash though![]()
Problem is solved by using signal and slots. I've created signals which connected to setText slots for each label. It works.
Thanks a lot.
Bookmarks