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. QT adding separator between the image in the listwidget
Forum Update on Monday, May 27th 2025

QT adding separator between the image in the listwidget

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 2.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.
  • A Offline
    A Offline
    amarism
    wrote on 15 Jun 2018, 07:05 last edited by VRonin
    #1

    I have a list widget and I am making the thumbnails inside the list widget. Now I need to separate the thumbnail image but when I used the code they will separate all the item inside the list widget. I am using this one code to separate the item:-

         QT_ThumblistWidget->setStyleSheet("QListWidget:item
                                                                              {border-bottom: 2px solid green;}
                                                                              QListWidget{background-color: black;}");
    

    also, I am attaching the screenshot for understanding what I am tried and what I need:-

    0_1529046177869_separator.png

    I need a separate only below the image but in my code separater are comes below the all the text and image.
    Thank you in advance

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 15 Jun 2018, 18:03 last edited by mrjj
      #2

      Hi
      But are the texts not also items ?
      So it put green unter text item
      and green under image item.

      so it seems it does what you ask it
      alt text

      Im not sure how you can tell stylesheet to ignore the text items.

      V 1 Reply Last reply 15 Jun 2018, 18:19
      0
      • M mrjj
        15 Jun 2018, 18:03

        Hi
        But are the texts not also items ?
        So it put green unter text item
        and green under image item.

        so it seems it does what you ask it
        alt text

        Im not sure how you can tell stylesheet to ignore the text items.

        V Offline
        V Offline
        VRonin
        wrote on 15 Jun 2018, 18:19 last edited by VRonin
        #3

        @mrjj said in QT adding separator between the image in the listwidget:

        Im not sure how you can tell stylesheet to ignore the text items.

        You can hack it. Since you always have 1 text and 1 image alternating you can use QListWidget::item:alternate to specify styles that apply only to every other item (http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qlistview)

        "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

        M 1 Reply Last reply 15 Jun 2018, 18:28
        2
        • V VRonin
          15 Jun 2018, 18:19

          @mrjj said in QT adding separator between the image in the listwidget:

          Im not sure how you can tell stylesheet to ignore the text items.

          You can hack it. Since you always have 1 text and 1 image alternating you can use QListWidget::item:alternate to specify styles that apply only to every other item (http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qlistview)

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Jun 2018, 18:28 last edited by
          #4

          @VRonin
          Ahh, excellent thinking!
          Remember to set.
          listWidget->setAlternatingRowColors(true);
          and it works. (tested)

          A 1 Reply Last reply 18 Jun 2018, 05:34
          1
          • M mrjj
            15 Jun 2018, 18:28

            @VRonin
            Ahh, excellent thinking!
            Remember to set.
            listWidget->setAlternatingRowColors(true);
            and it works. (tested)

            A Offline
            A Offline
            amarism
            wrote on 18 Jun 2018, 05:34 last edited by amarism
            #5

            @mrjj This one working fine by using the code:-
            Widget->setStyleSheet("QListWidget::item:alternate{border-bottom: 3px solid green;} QListWidget{background-color: black;}");
            Widget->setAlternatingRowColors(true);
            Thanks to all

            1 Reply Last reply
            1

            3/5

            15 Jun 2018, 18:19

            • Login

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