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?

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

Scheduled Pinned Locked Moved Unsolved Qt 6
8 Posts 4 Posters 1.0k 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 22 Jun 2022, 17:13 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"

    J 1 Reply Last reply 22 Jun 2022, 17:19
    0
    • R Riddler
      22 Jun 2022, 17:13

      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"

      J Offline
      J Offline
      JonB
      wrote on 22 Jun 2022, 17:19 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 22 Jun 2022, 17:40
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 22 Jun 2022, 17:38 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 22 Jun 2022, 17:56
        0
        • J JonB
          22 Jun 2022, 17:19

          @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 22 Jun 2022, 17:40 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
          • S SGaist
            22 Jun 2022, 17:38

            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 22 Jun 2022, 17:56 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
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 22 Jun 2022, 17:59 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 4 Jul 2022, 10:36
              0
              • S SGaist
                22 Jun 2022, 17:59

                Then I would check KDE's Kalendar .

                R Offline
                R Offline
                Riddler
                wrote on 4 Jul 2022, 10:36 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
                • J Offline
                  J Offline
                  JoeCFD
                  wrote on 4 Jul 2022, 19:15 last edited by JoeCFD 7 Apr 2022, 19:15
                  #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