Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How to use QListView, and set different spacing for different list items?
QtWS25 Last Chance

How to use QListView, and set different spacing for different list items?

Scheduled Pinned Locked Moved Unsolved Qt 6
8 Posts 4 Posters 988 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.
  • R Offline
    R Offline
    Riddler
    wrote on last edited by Riddler
    #1

    How to use QListView, and set different spacing for different list items?

    I want to create something to show events in a list. And those events are spaced in different times, have different pauses between them. I'd like to QListView for that (cause I like how it looks, and that you can make custom editor, and you can use model, and the animations, i like that). But I only found that you can set spacing for all of the items, that's the same. I need to be able to set different spacing/maring for different items. Like maybe between first and second item there's a 10px space, and between the second and the third maybe 30px, and then maybe 15px again, etc.

    It doesn't have to be QListView, but it should be able to have custom items (like one I can use with QItemDelegate) and should work with models, and also set custom spaceing between items.

    Is there something like this? I didn't find anything like a "Timeline component"

    JonBJ 1 Reply Last reply
    0
    • R Riddler

      How to use QListView, and set different spacing for different list items?

      I want to create something to show events in a list. And those events are spaced in different times, have different pauses between them. I'd like to QListView for that (cause I like how it looks, and that you can make custom editor, and you can use model, and the animations, i like that). But I only found that you can set spacing for all of the items, that's the same. I need to be able to set different spacing/maring for different items. Like maybe between first and second item there's a 10px space, and between the second and the third maybe 30px, and then maybe 15px again, etc.

      It doesn't have to be QListView, but it should be able to have custom items (like one I can use with QItemDelegate) and should work with models, and also set custom spaceing between items.

      Is there something like this? I didn't find anything like a "Timeline component"

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Riddler
      I don't think you can do this within QListView's properties. Unless someone knows better, I believe you need to write an item delegate to vary items in the way you describe.

      R 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        There's no pre-built timeline view. You can build your own. There example of full custom views in Qt's documentation.

        Maybe take a look at Kdenlive. They have a timeline component that may provide you with ideas.

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

        R 1 Reply Last reply
        0
        • JonBJ JonB

          @Riddler
          I don't think you can do this within QListView's properties. Unless someone knows better, I believe you need to write an item delegate to vary items in the way you describe.

          R Offline
          R Offline
          Riddler
          wrote on last edited by
          #4

          @JonB It doesn't have to be QListView. It can be anything that allows for using models and custom items.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            There's no pre-built timeline view. You can build your own. There example of full custom views in Qt's documentation.

            Maybe take a look at Kdenlive. They have a timeline component that may provide you with ideas.

            R Offline
            R Offline
            Riddler
            wrote on last edited by
            #5

            @SGaist Thanks, but that's not really the kind of timeline i'm looking for.

            I'm trying to create something similar to this:
            example.gif

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then I would check KDE's Kalendar .

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

              R 1 Reply Last reply
              0
              • SGaistS SGaist

                Then I would check KDE's Kalendar .

                R Offline
                R Offline
                Riddler
                wrote on last edited by
                #7

                @SGaist I'm not trying to create a calendar.

                I just want to add custom spacings to QListView.

                1 Reply Last reply
                0
                • JoeCFDJ Online
                  JoeCFDJ Online
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #8

                  Is it possible to add some empty rows and make them unselectable? If their texts are empty, ignore selections.

                  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