[Qt-interest] [MVC] Can signals connect / disconnect dynamically to reduce overhead on GUI thread?

Niklas Berglund niklas.berglund at gmail.com
Tue Nov 29 15:45:27 CET 2011


Consider being careful with premature optimization. Depending on the platform etc it might be better for your code design to leave them connected. 

Regards
Niklas

On 29 Nov, 2011, at 10:29 PM, Ed Sutton <ESutton at fescorp.com> wrote:

> 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



More information about the Qt-interest-old mailing list