[Qt-interest] [MVC] Can signals connect / disconnect dynamically to reduce overhead on GUI thread?
Bo Thorsen
bo at fioniasoftware.dk
Tue Nov 29 15:49:02 CET 2011
Ed, with that amount of emits, I would not use signals and slots. Go for
direct function calls instead. Signals and slots are a simplifying tool
that allows you to modularize the code. Don't use them when you have a
performance problem, because it's a no brainer to cut out the overhead
of the emits.
Of course, this doesn't matter if the slot spends an order of magnitude
more resources than the overhead. Only profiling can tell you this.
And always remember: Premature optimization is... :)
Bo.
Den 29-11-2011 15:29, Ed Sutton skrev:
> Thank you Thomas. Thank you Pritam.
>
> Each item is a network device. My concern was many signals connected to a few slots.
>
> 1 - If one item is selected in the treeview, the device being viewed will generates a continuos real-time stream of perhaps 10 signals per second of various parameters such as temperature, current, and voltage.
> 2 - If a group of 20 items is selected, in treeview , then 20*10 signals per second will be sent to update temperature, voltage, and current in a listview. For better GUI performance I suppose I might need to add a signalRatePerSecond property to throttle back the signals per second when many items are selected.
>
> Anyway, thank you both. I think I just need to dive into the MVC examples and figure it out.
>
> -Ed
>
>
> On Nov 29, 2011, at 1:50 AM, Thomas McGuire wrote:
>
>> Hi,
>>
>> On Tuesday 29 November 2011 06:05:25 Ed Sutton wrote:
>>> I am seeking design advice.
>>>
>>> My GUI is similar to the Windows File or Nautilus file explorer with a
>>> split windows interface; the left-pane selects the item to browse and the
>>> right-pane displays views of static and dynamic data. There could be
>>> hundreds of network devices in the left-pane tree view. My concern is the
>>> overhead of all these signal callbacks will overwhelm the GUI performance
>>> if connected to all of them. Can signals be connected to and disconnected
>>> dynamically to reduce the callback overhead on the GUI thread?
>>>
>>> [..]
>>>
>>> I am thinking I should use the Model View Controller (MVC) pattern. I am
>>> just not sure if the Qt disconnect is meant to be used this way?
>>
>> Using the model view framework in Qt is a good idea. This will solve your
>> problem automatically, since there is just a single signal when an item is
>> clicked, in your case that would be QTreeView::clicked(const QModelIndex&).
>> So there is one single signal for all items, so no overhead related to too
>> many connections.
>>
>> Regards,
>> Thomas
>> <smime.p7s>_______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
> -Ed
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list