A model might be solid—but what about the proxy sitting on top of it? Especially if it's written later by someone less experienced? This episode explores why index validation matters and introduces a library to help keep your data access safe:
www.youtube.com/watch?v=QGK6... #QtDev #QtWidgets
Introduction to Qt Widgets (Part 58) - Check Your Indexes
When you implement a model, it is worthwhile remembering that one day an intern, with far less experience than you, might implement a proxy model which sits on top of your model and acts as the view. This proxy model might be broken in ways you could even imagine, so better check that the index provided are actually referring to valid data in your model. This episode discusses this in details, and offers you a simple library with all checks needed. Chapters: 00:00 Welcome 00:26 Why is this important? 02:35 Over to the QWAM episode 03:36 The broken example 05:48 Hint to what is wrong 07:20 What is the cure? 08:05 What can I do to be more safe? 09:10 Qt 5.11 - checkIndex 12:39 CHECK_ macros 14:56 QAbstractProxyModel::headerData calling index for an invalid row Links: * QWAM: Communicating between view and model: https://youtu.be/q6eOEz_UfTI?list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI * Blog post on checkIndex: https://www.kdab.com/new-in-qt-5-11-improvements-to-the-model-view-apis-part-1/...