Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. data roles for model items
Forum Updated to NodeBB v4.3 + New Features

data roles for model items

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 450 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      U 1 Reply Last reply
      1
      • SGaistS SGaist

        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.

        U Offline
        U Offline
        user4592357
        wrote on last edited by
        #3

        @SGaist
        is the same true for roles from role enum that are not frequently used?

        also, what about my 2nd question in the post?

        SGaistS 1 Reply Last reply
        0
        • U user4592357

          @SGaist
          is the same true for roles from role enum that are not frequently used?

          also, what about my 2nd question in the post?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            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

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved