Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Should I create my own view



  • 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


  • Lifetime Qt Champion

    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.



  • 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


  • Lifetime Qt Champion

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



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



  • 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


  • Lifetime Qt Champion

    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.


Log in to reply