Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QT adding separator between the image in the listwidget

    General and Desktop
    3
    5
    1397
    Loading More Posts
    • 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
      amarism last edited by VRonin

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by 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.

        VRonin 1 Reply Last reply Reply Quote 0
        • VRonin
          VRonin @mrjj last edited by 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)

          "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

          mrjj 1 Reply Last reply Reply Quote 2
          • mrjj
            mrjj Lifetime Qt Champion @VRonin last edited by

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

            A 1 Reply Last reply Reply Quote 1
            • A
              amarism @mrjj last edited by amarism

              @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 Reply Quote 1
              • First post
                Last post