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. Should I create my own view
Qt 6.11 is out! See what's new in the release blog

Should I create my own view

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 524 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.
  • H Offline
    H Offline
    Harsaith
    wrote on last edited by
    #1

    Say that I have a SQLite database like this db.png

    and I want to show them to my user like this
    customview.png

    Should I create my own view ? What is the logical way to do it ? I want the data to be shown like this because I find it much prettier than putting them in a QTableView

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

      Hi

      Since it's a complete custom drawing, then yes, create your own view.

      After a better second look, I was wrong, all the content coming from the same row, you can use a delegate as @VRonin suggests.

      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
      1
      • H Offline
        H Offline
        Harsaith
        wrote on last edited by
        #3

        With that method will it be possible to open something like a popup to edit the fields when the use double-click on an item of my view ?

        Screenshot_57.png

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

          Yes, you will just be responsible to trigger the editor yourself.

          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
          1
          • H Offline
            H Offline
            Harsaith
            wrote on last edited by
            #5

            In the doc I found this sentence :

            The view classes that inherit QAbstractItemView only need to implement their own view-specific functionality, such as drawing items, returning the geometry of items, finding items, etc.
            

            What are those functionnality in term of methods ??? Does it mean I have to reimplement every virtual method in the class for my View ?

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

              To me this does not necessarily need a custom view. You just need a proxy model that maps data in the columns to a single column with multiple roles.
              Then QListView plus a custom delegate should do the trick

              "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
              4
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                After taking a second look at your picture following @VRonin's answer, I came to realize that I misread it. So indeed, you do not need a custom view (although it's an option). The suggestion of @VRonin is quite good and simpler.

                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
                2

                • Login

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