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
Forum Updated to NodeBB v4.3 + New Features

How to make the border have specific length in stylesheet

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtabbarqtabwidgetstylesheetborderstyle
5 Posts 5 Posters 612 Views 3 Watching
  • 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 18 Jan 2024, 14:17 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Jan 2024, 20:18 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 18 Jan 2024, 20:40 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!

        A G 2 Replies Last reply 20 Jan 2024, 18:25
        2
        • C CPPUIX
          18 Jan 2024, 20:40

          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!

          A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 20 Jan 2024, 18:25 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
            18 Jan 2024, 20:40

            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 20 Jan 2024, 22:57 last edited by
            #5

            @Abderrahmene_Rayene smart!

            1 Reply Last reply
            0

            5/5

            20 Jan 2024, 22:57

            • Login

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