Hi
I'm just wondering if doing something like widget->value() to read value is possible in thread. I'm just asking because doing it with signal/slots is a bit cumbersome.
Hi
I'm just wondering if doing something like widget->value() to read value is possible in thread. I'm just asking because doing it with signal/slots is a bit cumbersome.
No, it's not possible. You can operate on widget from the main thread only. You have to use events or signals to transfer widget related data across threads.
sirlore (24th June 2009)
thanks for fast reply.
I must say I was reading widgets in threads by just using pointers, as mentioned before, but any modification such as widget->setValue was made in main thread using signals slots. I haven't noticed any error or crush of my apps so far using this "method" of accessing widgets. There is no word about reading widgets "this way" in qt documentation, nor strict forbidding this.
To quote the docs:
Reading is "quite safe" most of the time in general. In most cases the worst thay may happen is that you get a wrong value. Notice the "in most cases" part... Of course you might be satisfied with your application working correctly "in most cases".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.
Bookmarks