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
QtWS25 Last Chance

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 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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.

      VRoninV 1 Reply Last reply
      0
      • mrjjM mrjj

        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.

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on 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

        mrjjM 1 Reply Last reply
        2
        • VRoninV VRonin

          @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)

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          A 1 Reply Last reply
          1
          • mrjjM mrjj

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

            A Offline
            A Offline
            amarism
            wrote on 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

            • Login

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