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. Scrollbar handle with rounded edges?
Forum Updated to NodeBB v4.3 + New Features

Scrollbar handle with rounded edges?

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 7.8k 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.
  • T Taytoo

    @mrjj said in Scrollbar handle with rounded edges?:

    QScrollBar:vertical {
                border: 0px solid #999999;
                background:white;
                width:10px;    
                margin: 0px 0px 0px 0px;
            }
            QScrollBar::handle:vertical {         
           
                min-height: 0px;
              	border: 0px solid red;
    			border-radius: 4px;
    			background-color: black;
            }
            QScrollBar::add-line:vertical {       
                height: 0px;
                subcontrol-position: bottom;
                subcontrol-origin: margin;
            }
            QScrollBar::sub-line:vertical {
                height: 0 px;
                subcontrol-position: top;
                subcontrol-origin: margin;
            }
    

    one thing to notice, your border-radius: 4px; and the width:10px; should match up.
    if you make it too narrow, it wont be round.

    It's working, but I'm unable to change the scrollbar's (not handle) background color.It's set to white, when I change it to Gray, the background becomes checkered. Also, tried adding background-color in add-line/sub-line but didn't work.

    KillerSmathK Offline
    KillerSmathK Offline
    KillerSmath
    wrote on last edited by
    #6

    @Taytoo
    Have you already check out the QT StyleSheet examples on Qt Documentation ?
    https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qscrollbar

    @Computer Science Student - Brazil
    Web Developer and Researcher
    “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #7

      Hi
      Its actually not the background but sub-page and add-page you see. if you remove color from them , then
      background works.

      add to stylesheet

      QScrollBar::sub-page:vertical {
      background: none;
      }

      QScrollBar::add-page:vertical {
      background: none;
      }

      alt text

      1 Reply Last reply
      3
      • T Offline
        T Offline
        Taytoo
        wrote on last edited by
        #8

        @mrjj said in Scrollbar handle with rounded edges?:

        QScrollBar::sub-page:vertical {
        background: none;
        }
        QScrollBar::add-page:vertical {
        background: none;
        }

        Working great.

        However, I also tried this on QTreeWidget, Qt Designer shows correct scrollbar but when I run the application, its showing standard windows scrollbar?

        and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?

        mrjjM 1 Reply Last reply
        0
        • T Taytoo

          @mrjj said in Scrollbar handle with rounded edges?:

          QScrollBar::sub-page:vertical {
          background: none;
          }
          QScrollBar::add-page:vertical {
          background: none;
          }

          Working great.

          However, I also tried this on QTreeWidget, Qt Designer shows correct scrollbar but when I run the application, its showing standard windows scrollbar?

          and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?

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

          @Taytoo
          Hi. it should also work for QTreeWidget.
          Do you apply it directly to it or to its parent ?

          -and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?

          You mean they are hidden but only shows when mouse is over ?
          lineEdits cannto have scrollbars.

          T 1 Reply Last reply
          0
          • mrjjM mrjj

            @Taytoo
            Hi. it should also work for QTreeWidget.
            Do you apply it directly to it or to its parent ?

            -and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?

            You mean they are hidden but only shows when mouse is over ?
            lineEdits cannto have scrollbars.

            T Offline
            T Offline
            Taytoo
            wrote on last edited by
            #10

            @mrjj said in Scrollbar handle with rounded edges?:

            @Taytoo
            Hi. it should also work for QTreeWidget.
            Do you apply it directly to it or to its parent ?

            I applied stylesheet to QTreeWidget

            -and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?
            You mean they are hidden but only shows when mouse is over ?

            Yes

            lineEdits cannto have scrollbars.

            typo...I meant QPlainTextEdit

            mrjjM 1 Reply Last reply
            0
            • T Taytoo

              @mrjj said in Scrollbar handle with rounded edges?:

              @Taytoo
              Hi. it should also work for QTreeWidget.
              Do you apply it directly to it or to its parent ?

              I applied stylesheet to QTreeWidget

              -and is it possible to have scrollbar only disable when mouse enters the widget scrollbar is attached to e.g. on line edit or treewidget?
              You mean they are hidden but only shows when mouse is over ?

              Yes

              lineEdits cannto have scrollbars.

              typo...I meant QPlainTextEdit

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

              @Taytoo
              Hi
              can you try applying it to main window instead.
              (i assume the QTreeWidget lives in mainwin)

              Well show on hover thing is not included by default.
              I think you can make it work by overriding Enter/Leave
              events
              https://doc.qt.io/qt-5/qwidget.html#enterEvent
              and show hide the scrollbars.
              If you dont want to subclass, you can also try with
              Event filter
              https://doc.qt.io/qt-5/eventsandfilters.html

              .

              T 1 Reply Last reply
              1
              • mrjjM mrjj

                @Taytoo
                Hi
                can you try applying it to main window instead.
                (i assume the QTreeWidget lives in mainwin)

                Well show on hover thing is not included by default.
                I think you can make it work by overriding Enter/Leave
                events
                https://doc.qt.io/qt-5/qwidget.html#enterEvent
                and show hide the scrollbars.
                If you dont want to subclass, you can also try with
                Event filter
                https://doc.qt.io/qt-5/eventsandfilters.html

                .

                T Offline
                T Offline
                Taytoo
                wrote on last edited by Taytoo
                #12

                @mrjj That worked. Thanks!

                One would assume since scrollbar is in QTreeWidget, the style needs to be applied there though?

                PS. I wanted to mark your post as the answer/solution, but the forum only allows me to mark my post as the answer?

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

                  Hi,

                  @Taytoo said in Scrollbar handle with rounded edges?:

                  PS. I wanted to mark your post as the answer/solution, but the forum only allows me to mark my post as the answer?

                  That's a NodeBB issue. What answer did you want to mark as the solution ?

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

                  T 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    @Taytoo said in Scrollbar handle with rounded edges?:

                    PS. I wanted to mark your post as the answer/solution, but the forum only allows me to mark my post as the answer?

                    That's a NodeBB issue. What answer did you want to mark as the solution ?

                    T Offline
                    T Offline
                    Taytoo
                    wrote on last edited by
                    #14

                    @SGaist mrjj's first reply to my post answered the main question. Later posts were all about tweaks, so I guess first reply is the answer.

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

                      Done :-)

                      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
                      1

                      • Login

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