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. QListWidget with dynamic icons
QtWS25 Last Chance

QListWidget with dynamic icons

Scheduled Pinned Locked Moved Solved General and Desktop
qlistwidgetqlistwidgetitemicon
12 Posts 2 Posters 5.5k 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.
  • H Offline
    H Offline
    Harry123
    wrote on 31 Mar 2016, 11:33 last edited by
    #1

    I would like to have a QListWidget with many items, each containing text and icon in the standard manner. The text identifies the icon, meaning that the icon can be retrieved by using the text as the key.

    My problem is that retrieving the icons is a relatively slow operation. Setting up the QListWidget would be much faster if I could only supply the text-part when initially creating the QListWidgetItem, later adding the icons only for the items that are really going to be displayed.

    Is there a method by which I could intercept the display of a QListWidgetItem and add the icon just before the item is displayed?

    I know that I can do this using QListView, but QListWidget already does much of the needed work.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 31 Mar 2016, 19:19 last edited by
      #2

      Hi,

      What about delegating the icon load to anther thread and then signal a data change when they are ready ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Harry123
        wrote on 31 Mar 2016, 19:43 last edited by Harry123
        #3

        I would really prefer to avoid creating icons that will never be looked at, if possible.
        I might find myself creating 1000 icons, while the user will never look at more than the first few screens.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Mar 2016, 20:17 last edited by
          #4

          Sorry, I just saw that my suggestion is incomplete. Your model should be queried when needed for the icons so what I was suggesting is that when one is queried, you start loading it and then trigger the dataChanged signal.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply 1 Apr 2016, 11:50
          0
          • S SGaist
            31 Mar 2016, 20:17

            Sorry, I just saw that my suggestion is incomplete. Your model should be queried when needed for the icons so what I was suggesting is that when one is queried, you start loading it and then trigger the dataChanged signal.

            H Offline
            H Offline
            Harry123
            wrote on 1 Apr 2016, 11:50 last edited by
            #5

            @SGaist

            Could you please add more details about this procedure.
            I never used model/view.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Apr 2016, 20:19 last edited by
              #6

              Which part would like to have more detail on ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              H 1 Reply Last reply 2 Apr 2016, 10:05
              0
              • S SGaist
                1 Apr 2016, 20:19

                Which part would like to have more detail on ?

                H Offline
                H Offline
                Harry123
                wrote on 2 Apr 2016, 10:05 last edited by Harry123 4 Feb 2016, 10:06
                #7

                @SGaist

                I would prefer to use QListWidget, because it is much simpler than using model/view with which I have no experience.
                I need some pointers as to what should be done - classes and functions to call.

                I myself was thinking more in the direction of connecting to the vertical scrollbar of QListWidget and anticipating scrolls, but I'm not sure I would guess correctly from the scroll events exactly which items will be displayed.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Apr 2016, 20:33 last edited by
                  #8

                  If you use QListWidget then you don't have any control over the model so you won't be able to move the image loading part outside of it.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply 4 Apr 2016, 10:45
                  0
                  • S SGaist
                    2 Apr 2016, 20:33

                    If you use QListWidget then you don't have any control over the model so you won't be able to move the image loading part outside of it.

                    H Offline
                    H Offline
                    Harry123
                    wrote on 4 Apr 2016, 10:45 last edited by
                    #9

                    @SGaist

                    I have basically given up on using QListWidget that efficiently.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 4 Apr 2016, 19:40 last edited by
                      #10

                      What option did you choose ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      H 1 Reply Last reply 14 Apr 2016, 07:16
                      0
                      • S SGaist
                        4 Apr 2016, 19:40

                        What option did you choose ?

                        H Offline
                        H Offline
                        Harry123
                        wrote on 14 Apr 2016, 07:16 last edited by
                        #11

                        @SGaist

                        I have divided the list into sections, and modified the UI to show only one section at a time.
                        This solved the performance problem (and maybe even made the UI more user-friendly).

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 14 Apr 2016, 09:48 last edited by
                          #12

                          It's good when it's more friendly :)

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1

                          • Login

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