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. Custom list view
QtWS25 Last Chance

Custom list view

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 3.8k Views
  • 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 Offline
    D Offline
    Defohin
    wrote on last edited by Defohin
    #1

    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-worxR 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      3
      • D Offline
        D Offline
        Defohin
        wrote on last edited by
        #3

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

        torrent

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

          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
          1
          • D 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-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by raven-worx
            #5

            @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
            2
            • raven-worxR 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.

              D Offline
              D Offline
              Defohin
              wrote on last edited by
              #6

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

              mrjjM raven-worxR 2 Replies Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                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
                3
                • D Defohin

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @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-worxR 1 Reply Last reply
                  2
                  • D Offline
                    D Offline
                    Defohin
                    wrote on last edited by
                    #9

                    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
                    1
                    • D Defohin

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

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

                      @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
                      0
                      • mrjjM 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-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by raven-worx
                        #11

                        @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

                        mrjjM 1 Reply Last reply
                        0
                        • raven-worxR 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.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #12

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

                          • Login

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