Posts

Showing posts from March, 2019

Improving the performance of UI list updates

My experience has shown that a recurrent problem in editors is updating lists of objects in a user interface fast . Example: entities in a level. Layers in a scene, etc, etc. An implementation usually stores the objects separately and an extra list of the object pointers in the UI classes themselves. Such lists might, for instance be stored in an array inside a subclass of a QAbstractItemModel if one works in Qt. Note: The code below does not use standard library classes, but it should hopefully be somewhat easy to follow Updating In a naive, object oriented approach there is a set method in our entity class. An implementation might look like this: 1 2 3 4 5 void Entity :: setName(String name) { m_Name = name; m_NameChangedSignal( this ); } Our UI class is a listener of the m_NameChangedSignal (which might be an implementation of signals as in my previous post on variadic templates ) and as soon as the name is set, an update is fired. Our UI class'