Re: emit is slow in Thread?
Don't emit 10000 signals. Of course it will be slow, because the GUI event handler will have to handle 10000 events.
Instead emit fewer signals, but containing more data.
F.e. emit 100 signals that each add 100 items to the widget. Probably you will have to cache the item data.
Still, there will be a delay, but the application will be more responsive.
Regards
Re: emit is slow in Thread?
OK.
I will try this.
I want to ask one more thing that can I take a return value from the emit signal because I want this QTreeWidgetItem pointer to be added in the list which is in thread.
Re: emit is slow in Thread?
Quote:
Originally Posted by
vishal.chauhan
OK.
I will try this.
I want to ask one more thing that can I take a return value from the emit signal because I want this QTreeWidgetItem pointer to be added in the list which is in thread.
No, you can't have a return value for a signal./ This is mainly because you don't actually implement the signals. You just declare them. The "implementation" is done by moc.
Code:
because I want
this QTreeWidgetItem pointer to be added in the list which is in thread
Create a small class or struct that has a few members(public, nothing fancy).
You emit the signal with this an instance of this class as parameter. In the worker thread, before you emit, populate the class with the needed data( the tree item, and whatever you may need in the GUI thread, when you receive the signal ).
Be careful that when emitting signals with custom types, these types have to be registered with Qt.
See qRegisterMetaType.
Regards