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. Listing with custom widget
QtWS25 Last Chance

Listing with custom widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.3k 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.
  • Y Offline
    Y Offline
    yugosonegi
    wrote on 19 Dec 2017, 13:19 last edited by yugosonegi
    #1

    I'm new to Qt and I'm trying to create a software that is going to have a listing, like a list of things. I'm going to give you some images of softwares that does that:

    You see the listing that is with some icons, the title, the progressbae and stuff.

    I was wondering how to create this and how to handle each one of them, for example, if I'm downloading one of them I can set the progress for that item?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 19 Dec 2017, 16:37 last edited by
      #2

      it's a QStyledItemDelegate subclass, the progress is just a double save in a role of the model

      "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
      1
      • Y Offline
        Y Offline
        yugosonegi
        wrote on 19 Dec 2017, 17:02 last edited by
        #3

        Is there any tutorial where I can read or watch about that or creating something similar to that?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 19 Dec 2017, 18:45 last edited by
          #4

          Hi
          the
          http://doc.qt.io/qt-5/qtnetwork-torrent-example.html
          has mainwindow.cpp
          class TorrentViewDelegate : public QItemDelegate

          Which is the same just with the older class
          "Note that QStyledItemDelegate has taken over the job of drawing Qt's item views. We recommend the use of QStyledItemDelegate when creating new delegates."

          It just draws a progressbar with QStyleOptionProgressBar
          but you just need to draw other stuff you want.

          This is the correct way and have good performance with many list items.

          Can i ask how many items you will have?

          1 Reply Last reply
          3
          • Y Offline
            Y Offline
            yugosonegi
            wrote on 19 Dec 2017, 19:56 last edited by
            #5

            @mrjj said in Listing with custom widget:

            many

            I don't have yet but I'm planing in having only two or three icon, a title, a button, a progress bar.

            M 1 Reply Last reply 19 Dec 2017, 20:01
            0
            • Y yugosonegi
              19 Dec 2017, 19:56

              @mrjj said in Listing with custom widget:

              many

              I don't have yet but I'm planing in having only two or three icon, a title, a button, a progress bar.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 19 Dec 2017, 20:01 last edited by mrjj
              #6

              @yugosonegi
              Ok, should not be that much extra code to draw.
              Note that the sample only draws the things.
              To make it active, like the button, you must also implement editing feature
              that shows a real button so its clickable,
              This sampel show an active one
              http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
              The
              QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
              const QModelIndex &index) const override;
              is key here. It will allow you to create a real button/widget and not a picture of it
              for the current /selected item/row and hence you can click it etc.

              1 Reply Last reply
              2

              6/6

              19 Dec 2017, 20:01

              • Login

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