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. ListWidget with a lot of items
QtWS25 Last Chance

ListWidget with a lot of items

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlistwidgetcustom widgetitemdelegateqstyleditemdele
5 Posts 2 Posters 529 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.
  • E Offline
    E Offline
    Emrecp
    wrote on 1 Jul 2023, 18:56 last edited by Emrecp 7 Jan 2023, 18:58
    #1

    Picture: https://ibb.co/Hp4XCjT
    ask.png
    Hello, I want to implement the thing that I will add a picture of in Qt. There are some things to consider here. First, there could be almost 300 games. The second thing is that when a game is hovered over, the card of the game should enlarge, and buttons with information about the game should appear below and these buttons should be clickable.

    I am thinking of doing this with QListWidget and a custom delegate, but I have not been very successful, maybe there is an easier and better way, I would also like to learn that from you. Thank you.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jeremy_k
      wrote on 2 Jul 2023, 05:33 last edited by
      #2

      Given the choice, I would implement this in QML rather than with QListView.

      ListView {
          orientation: ListView.Horizontal
          delegate: MouseArea {
              id: mouseArea
              width: containsMouse? 100 : 50
              height: containsMouse ? 100 : 50
              hoverEnabled: true
              Image {
                  anchors.fill: parent
              }
              Button {
                  anchors.bottom: parent.bottom
                  visible: mouseArea.containsMouse
              }
          }
      }
      

      300 items in the list should not be a problem with adequate hardware. The view will manage creating and destroying delegate instances as necessary.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      E 1 Reply Last reply 2 Jul 2023, 06:28
      0
      • J jeremy_k
        2 Jul 2023, 05:33

        Given the choice, I would implement this in QML rather than with QListView.

        ListView {
            orientation: ListView.Horizontal
            delegate: MouseArea {
                id: mouseArea
                width: containsMouse? 100 : 50
                height: containsMouse ? 100 : 50
                hoverEnabled: true
                Image {
                    anchors.fill: parent
                }
                Button {
                    anchors.bottom: parent.bottom
                    visible: mouseArea.containsMouse
                }
            }
        }
        

        300 items in the list should not be a problem with adequate hardware. The view will manage creating and destroying delegate instances as necessary.

        E Offline
        E Offline
        Emrecp
        wrote on 2 Jul 2023, 06:28 last edited by
        #3

        @jeremy_k I am not using QML in my project. So Do you think the best way would be to use qlistview instead of qlistwidget?

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jeremy_k
          wrote on 2 Jul 2023, 06:51 last edited by
          #4

          QListWidget is QListView with a built-in model roughly equivalent to QStandardItemModel. I try to avoid the Q*Widget views because deeper control of the model is useful for my tasks. Much of the time, they work just as well for models without a more efficient representation or lifetime that doesn't match the view.

          Is the decision to not use QML due to Qt widget use elsewhere in the project, lack of familiarity, concerns about performance, or something else? Guessing that lots of other people have attempted to implement this UI with QML, I did a search and found https://github.com/driskiou/netflix-clone
          I have not watched the YouTube video linked in the project description. The claim of 3 hours of development time does not sound unreasonable.

          Widgets are great for creating a desktop application that looks like other desktop applications, particularly in the era that the widgets were created. That doesn't match the screen shot in the first post. It can be done, but it means writing the delegate from scratch. Perhaps if the nature of not [...] very successful is explained (including code), someone can provide some tips.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          E 1 Reply Last reply 4 Jul 2023, 20:39
          1
          • J jeremy_k
            2 Jul 2023, 06:51

            QListWidget is QListView with a built-in model roughly equivalent to QStandardItemModel. I try to avoid the Q*Widget views because deeper control of the model is useful for my tasks. Much of the time, they work just as well for models without a more efficient representation or lifetime that doesn't match the view.

            Is the decision to not use QML due to Qt widget use elsewhere in the project, lack of familiarity, concerns about performance, or something else? Guessing that lots of other people have attempted to implement this UI with QML, I did a search and found https://github.com/driskiou/netflix-clone
            I have not watched the YouTube video linked in the project description. The claim of 3 hours of development time does not sound unreasonable.

            Widgets are great for creating a desktop application that looks like other desktop applications, particularly in the era that the widgets were created. That doesn't match the screen shot in the first post. It can be done, but it means writing the delegate from scratch. Perhaps if the nature of not [...] very successful is explained (including code), someone can provide some tips.

            E Offline
            E Offline
            Emrecp
            wrote on 4 Jul 2023, 20:39 last edited by
            #5

            Can anyone share sample code for qlistwidget or qlistview?

            1 Reply Last reply
            0

            5/5

            4 Jul 2023, 20:39

            • Login

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