Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Model View customized requirement
Forum Updated to NodeBB v4.3 + New Features

Model View customized requirement

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 4 Posters 511 Views 1 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.
  • V Offline
    V Offline
    Vinoth Rajendran4
    wrote on last edited by
    #1

    Hi All,

    Initial project requirement was as below,

    846535e9-6361-4f78-a0f9-b57cf3ecd315-image.png

    Hence I used GridView to implement this.

    But now the requirement is changed, the expectation is

    9a13bebf-a5b2-49ae-a2fd-c59971e76cfb-image.png

    But its expected we follow the index such as
    p1 = 0'th index,
    p2 = 1st index,
    p3 = 2nd index,
    p4 = 3rd index,
    p5 = 4th index,
    p6 = 5th index,
    p7 = 6th index.

    The model data comes from C++ backend. currently backend is implemented by sub classing QAbstractListModel.

    Please let me know, how to approach this problem.

    Thanks!

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Just put empty data in the blank ones.

      C++ is a perfectly valid school of magic.

      V 1 Reply Last reply
      0
      • fcarneyF fcarney

        Just put empty data in the blank ones.

        V Offline
        V Offline
        Vinoth Rajendran4
        wrote on last edited by Vinoth Rajendran4
        #3

        @fcarney : But those empty data also have index. I don't want index to be associated with empty data.

        JonBJ 1 Reply Last reply
        0
        • V Offline
          V Offline
          Vinoth Rajendran4
          wrote on last edited by
          #4

          If not possible with GridView, is there any other model view using which this can be achieved ?

          1 Reply Last reply
          0
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            Will you always have only 7 items? Should it only be the layout you displayed or the empty cells can shift?

            V 1 Reply Last reply
            0
            • V Vinoth Rajendran4

              @fcarney : But those empty data also have index. I don't want index to be associated with empty data.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Vinoth-Rajendran4 said in Model View customized requirement:

              But those empty data also have index. I don't want index to be associated with empty data.

              So what exactly do you want then?

              Anyway, ISTM you have two choices:

              • Subclass/derive from some QLayout (e.g. possibly QGridlayout) and implement your desired layout with "blank" cells.
              • Interpose a QAbstractProxyModel-derived class (QIdentityProxyModel should be a good starting point) and have that deal with the indexes so that it returns "invalid index" where you want blanks in the QGridLayout. This means that while the proxy model returns some blank indexes your underlying model does not have to have such "gaps" in it.

              EDIT
              Oh, I'm so sorry, I only just noticed this is GridView/QML, not widgets application. I will leave the above in, I don't know is is meshes with how to do things in QML...? Hopefully the second option is still applicable?

              1 Reply Last reply
              1
              • GrecKoG GrecKo

                Will you always have only 7 items? Should it only be the layout you displayed or the empty cells can shift?

                V Offline
                V Offline
                Vinoth Rajendran4
                wrote on last edited by
                #7

                @GrecKo : empty cells can shift dynamically.

                1 Reply Last reply
                0
                • GrecKoG Offline
                  GrecKoG Offline
                  GrecKo
                  Qt Champions 2018
                  wrote on last edited by
                  #8

                  How are the cell positions determined?

                  A GridLayout + a Repeater could work.

                  1 Reply Last reply
                  0

                  • Login

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