Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. model/view
Qt 6.12 LTS is out! See what's new in the release blog

model/view

Scheduled Pinned Locked Moved Unsolved General and Desktop
26 Posts 3 Posters 22.0k 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.
  • raven-worxR raven-worx

    @user4592357
    For tables: QAbstractTableModel
    For trees: QAbstractItemModel

    But i suggest you first implement a table model, before jumping onto the tree model implementation, for the sake of simplicity.

    About how many cells in the end are we talking actually?
    If we are not talking about hundreds to thousands you can also use QStandartItems (with QTreeWidget/QTableWidget) as @VRonin suggested.

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

    @raven-worx
    the cells are a lot actually

    and about your code snippet, what if the row/column values aren't known beforehand?

    1 Reply Last reply
    0
    • raven-worxR raven-worx

      @user4592357
      For tables: QAbstractTableModel
      For trees: QAbstractItemModel

      But i suggest you first implement a table model, before jumping onto the tree model implementation, for the sake of simplicity.

      About how many cells in the end are we talking actually?
      If we are not talking about hundreds to thousands you can also use QStandartItems (with QTreeWidget/QTableWidget) as @VRonin suggested.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #17

      @raven-worx said in model/view:

      If we are not talking about hundreds to thousands you can also use QStandartItems

      I actually use tens of thousands tree elements with QStandartItemModel and works for me

      "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

      raven-worxR 1 Reply Last reply
      0
      • VRoninV VRonin

        @raven-worx said in model/view:

        If we are not talking about hundreds to thousands you can also use QStandartItems

        I actually use tens of thousands tree elements with QStandartItemModel and works for me

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #18

        @VRonin said in model/view:

        I actually use tens of thousands tree elements with QStandartItemModel and works for me

        i never said it's not working, but it's a waste of memory.
        And thus discouraged to do so (from my side).

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        U 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @VRonin said in model/view:

          I actually use tens of thousands tree elements with QStandartItemModel and works for me

          i never said it's not working, but it's a waste of memory.
          And thus discouraged to do so (from my side).

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

          @raven-worx
          about your code snippet, what if the row/column values aren't known beforehand?

          raven-worxR 1 Reply Last reply
          0
          • U user4592357

            @raven-worx
            about your code snippet, what if the row/column values aren't known beforehand?

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #20

            @user4592357
            then reusing the QHash structure is not ideal, you could use your matrix approach then

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            U 1 Reply Last reply
            0
            • raven-worxR raven-worx

              @user4592357
              then reusing the QHash structure is not ideal, you could use your matrix approach then

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

              @raven-worx
              can't i use QTableWidget and QTreeWidget since my models aren't reused?

              VRoninV 1 Reply Last reply
              0
              • U user4592357

                @raven-worx
                can't i use QTableWidget and QTreeWidget since my models aren't reused?

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #22

                @user4592357 That's basically the same as using QStandartItemModel that we suggested at the beginning

                "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

                U 1 Reply Last reply
                0
                • VRoninV VRonin

                  @user4592357 That's basically the same as using QStandartItemModel that we suggested at the beginning

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

                  @VRonin
                  how is it the same?

                  should i use the same QStandartItemModel for both views?

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

                    I mean QStandartItemModel + QTreeView = QTreeWidget and QStandartItemModel + QTableView = QTableWidget

                    "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

                    U 1 Reply Last reply
                    1
                    • VRoninV VRonin

                      I mean QStandartItemModel + QTreeView = QTreeWidget and QStandartItemModel + QTableView = QTableWidget

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

                      @VRonin @raven-worx
                      i have another question.

                      so my table widget consists of 2 widgets: QTableView and a QTextEdit under it to display info about a particular cell.

                      the data container i use to set model data consists of two maps:

                      1. data storage for table view
                      2. data storage for text edit

                      how should i handle this in data()?

                      1 Reply Last reply
                      0
                      • U Offline
                        U Offline
                        user4592357
                        wrote on last edited by
                        #26

                        should i user two different containers???

                        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
                        • Unsolved