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. How to make the border have specific length in stylesheet
QtWS25 Last Chance

How to make the border have specific length in stylesheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtabbarqtabwidgetstylesheetborderstyle
5 Posts 5 Posters 581 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.
  • S Offline
    S Offline
    Serafim Rafail
    wrote on last edited by
    #1

    Screenshot 2024-01-18 200745.png

    Here i have a top border of 2px and i want reduce the length of the border how can i do this ?

    here is an idea of how i want
    Screenshot 2024-01-18 201403.png

    my current stylesheet :
    QTabBar::tab:selected
    {
    background-color: rgb(97, 95, 93);
    border-top: 3px solid #ffffff;
    }

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

      Hi,

      AFAIK, you can't with stylesheet. You will have to paint that yourself.

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CPPUIX
        wrote on last edited by CPPUIX
        #3

        Hi,

        I think I have something for you, which is a trick I found to achieve that as well. I'm not sure I could call it a solution, but I think it might be what you need.

        As described in my answer on Stack Overflow — How to get bracket style border for QWidget using stylesheets, you could use QLinearGradient:

        background-color: rgb(255, 255, 255);
        border: 5px solid qlineargradient(spread: pad,x1:0, y1:0, x2:1, y2:0, 
                   stop: 0 green,
                   stop: 0.2 green,
                   stop: 0.21 white,
                   stop: 0.8 white,
                   stop: 0.81 green
                   stop: 1 green);
        border-left:  5px solid green;
        border-right: 5px solid green;
        

        Just adjust the stops values and the colors, and see if it works for you.

        Important: there needs to be a small fraction separating them to achieve a solid color.

        Hope it helps!

        Axel SpoerlA G 2 Replies Last reply
        2
        • C CPPUIX

          Hi,

          I think I have something for you, which is a trick I found to achieve that as well. I'm not sure I could call it a solution, but I think it might be what you need.

          As described in my answer on Stack Overflow — How to get bracket style border for QWidget using stylesheets, you could use QLinearGradient:

          background-color: rgb(255, 255, 255);
          border: 5px solid qlineargradient(spread: pad,x1:0, y1:0, x2:1, y2:0, 
                     stop: 0 green,
                     stop: 0.2 green,
                     stop: 0.21 white,
                     stop: 0.8 white,
                     stop: 0.81 green
                     stop: 1 green);
          border-left:  5px solid green;
          border-right: 5px solid green;
          

          Just adjust the stops values and the colors, and see if it works for you.

          Important: there needs to be a small fraction separating them to achieve a solid color.

          Hope it helps!

          Axel SpoerlA Offline
          Axel SpoerlA Offline
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          @Abderrahmene_Rayene
          A creative solution! The inventors of QStyleSheetwould probably have said "doesn't work" - and be surprised.

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          1
          • C CPPUIX

            Hi,

            I think I have something for you, which is a trick I found to achieve that as well. I'm not sure I could call it a solution, but I think it might be what you need.

            As described in my answer on Stack Overflow — How to get bracket style border for QWidget using stylesheets, you could use QLinearGradient:

            background-color: rgb(255, 255, 255);
            border: 5px solid qlineargradient(spread: pad,x1:0, y1:0, x2:1, y2:0, 
                       stop: 0 green,
                       stop: 0.2 green,
                       stop: 0.21 white,
                       stop: 0.8 white,
                       stop: 0.81 green
                       stop: 1 green);
            border-left:  5px solid green;
            border-right: 5px solid green;
            

            Just adjust the stops values and the colors, and see if it works for you.

            Important: there needs to be a small fraction separating them to achieve a solid color.

            Hope it helps!

            G Offline
            G Offline
            gigs
            wrote on last edited by
            #5

            @Abderrahmene_Rayene smart!

            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