Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Custom list view

    General and Desktop
    4
    12
    3125
    Loading More Posts
    • 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.
    • D
      Defohin last edited by Defohin

      How to create a custom list view like this:

      list view

      I can't find anything on the internet showing something similar to that.

      raven-worx 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        I would have a look at
        http://doc.qt.io/qt-5/qtnetwork-torrent-example.html
        It has something alike :)

        1 Reply Last reply Reply Quote 3
        • D
          Defohin last edited by

          With "alike" you mean the view, model and delegate thing or the appearance?

          torrent

          1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            The delegate I guess :) ( or whole concept of a "downloding" row)
            as you need to use a delegate to make such custom list.

            1 Reply Last reply Reply Quote 1
            • raven-worx
              raven-worx Moderators @Defohin last edited by raven-worx

              @Defohin
              i suggest not using a listview for this. Since IMO it is just unnecessary overhead.

              Instead i suggest you use a QScrollArea with a QVBoxLayout (stretch at the end) in it, containing all the item widgets.

              If you need the selection this could also simply be "simulated" with other techniques.

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

              D 1 Reply Last reply Reply Quote 2
              • D
                Defohin @raven-worx last edited by

                @mrjj Is the delegate responsible for drawing the things on the view? For example, in the image I shared you can see a thumbnail, is the delegate responsible for drawing that?

                @raven-worx Don't you think that using widgets, QScrollArea and QVBoxLayout is going to be worse? I'm going to be using database, adding and removing data, probably dragging and dropping, organizing the list, etc.

                mrjj raven-worx 2 Replies Last reply Reply Quote 0
                • VRonin
                  VRonin last edited by

                  A custom delegate on a QListView is definitely the way to go.

                  @Defohin said in Custom list view:

                  Is the delegate responsible for drawing the things on the view?

                  The delegate is responsible for painting items within the view via the paint method

                  "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 Reply Quote 3
                  • mrjj
                    mrjj Lifetime Qt Champion @Defohin last edited by mrjj

                    @Defohin said in Custom list view:

                    @mrjj Is the delegate responsible for drawing the things on the view? For example, in the image I shared you can see a thumbnail, is the delegate responsible for drawing that?

                    yes. The delegate arguments the view and you alter how it draw stuff that way. OR to provide new editor for
                    some cells.
                    http://www.informit.com/articles/article.aspx?p=1405547&seqNum=4

                    I agree with @raven-worx that if you can cheat and just
                    just a QWidget as a "row"and stuff your widgets there. It would be much faster to make it
                    and as long you dont need 1000000 of them. it will perform ok.
                    I would maybe looking into a TableWidget with one column and setCellWidget
                    if that would give me selection and drag and drop for free. (not tested)

                    raven-worx 1 Reply Last reply Reply Quote 2
                    • D
                      Defohin last edited by

                      I will try the approaches listed here and see what happens.
                      I will create another thread or resurrect this one. Thank you all.

                      1 Reply Last reply Reply Quote 1
                      • raven-worx
                        raven-worx Moderators @Defohin last edited by

                        @Defohin said in Custom list view:

                        Don't you think that using widgets, QScrollArea and QVBoxLayout is going to be worse?

                        no, otherwise i wouldn't suggest it ;)

                        I'm going to be using database, adding and removing data, probably dragging and dropping, organizing the list, etc.

                        It depends. If you use a lot of features from the model/view framework and gain benefit from it, you of course can also go this way.
                        Nevertheless, i just suggested. In the end both approaches are possible/valid to go.

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

                        1 Reply Last reply Reply Quote 0
                        • raven-worx
                          raven-worx Moderators @mrjj last edited by raven-worx

                          @mrjj said in Custom list view:

                          I would maybe looking into a TableWidget with one column and setCellWidget
                          if that would give me selection and drag and drop for free. (not tested)

                          if the widget doesn't consume the mouse-events and propagates them up to the viewport it should work.
                          Starting the drag has also be implemented, or otherwise the drag-image will be the empty cell instead.

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

                          mrjj 1 Reply Last reply Reply Quote 0
                          • mrjj
                            mrjj Lifetime Qt Champion @raven-worx last edited by mrjj

                            @raven-worx
                            It eats them :) (check box did)
                            For dragging it uses the items text so that look odd :)

                            So im not sure it gives much over a
                            QScrollArea with a QVBoxLayout as you suggest.
                            You would still need event filter (or way, mouse pass though/ignore)
                            to make row select on clicking on any widget in the "row"
                            and still need to startDrag if you want the look of the actual row.
                            So not so much "free" as I thought. :)

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post