I am building a tree using QStandardItemModel and populating it with QStandardItems. I am wrapping some data about each item into an object that I then aim to set as the data with role = UserRole. I am presently doing the following:
QStandardItem.setData(object, role = QtCore.Qt.UserRole)
To copy to clipboard, switch view to plain text mode
My question is about the documentation for setData(). It says to call setData() with:
QStandardItem.setData(value, role=Qt.UserRole + 1])
To copy to clipboard, switch view to plain text mode
I am confused by the "+1".
Since Qt.UserRole = 32, does the +1 mean I should set role to 33? This seems very strange, unless I have multiple different UserRoles to employ, in which case I thought I could start with 32, and go from there. But I don't, I just have one such userRole (for now). Can I use Qt.UserRole, or do I need to start with Qt.UserRole+1?
So far I am just using Qt.UserRole, and it seems to be working ok, but I worry there is some corner case I will hit where the thing will blow up.
Bookmarks