Solved data roles for model items
-
i've heard that the model's data() checks for some default roles. and if the user adds any other role than the default set, then the data() method might become slow. is that true?
also, is it important to list the roles in data() in the order that they appear in the enum? -
Hi,
Models can get slower if you ask for huge amount of data.
Adding new roles won't affect its speed as long as you write the data method properly.
-
@SGaist
is the same true for roles from role enum that are not frequently used?also, what about my 2nd question in the post?
-
@user4592357 said in data roles for model items:
@SGaist
is the same true for roles from role enum that are not frequently used?What do you mean by that ?
also, what about my 2nd question in the post?
AFAIK, it won't have much impact. But again, it depends on how you write your function. As series of if is likely going to be less efficient than the use of a switch.
-
models are just an interface (
QAbstractItemModel
). They are not fast nor slow. They depend exclusively on the implementation you write.is it important to list the roles in data() in the order that they appear in the enum?
No. So far any method in Qt that depended on the order of roles was considered to be bugged as the order should not matter