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. QScrollBar - Hiding add-line and sub-line when moved

QScrollBar - Hiding add-line and sub-line when moved

Scheduled Pinned Locked Moved General and Desktop
qscrollbarscrollscrollbar
2 Posts 2 Posters 5.5k 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.
  • M Offline
    M Offline
    mat_de_b
    wrote on last edited by
    #1

    I am having a problem attempting to customise the stylesheet for my QScrollBars.

    I have added images in the stylesheet for the handle, add-line and sub-line. However when i move the handle it is hiding the add-line/sub-line images and is creating a shadow at either end. I have set the background colour as green to emphasise the problem.

    Add-line and handle displayed correctlyAdd-line now half maskedAdd-line now hidden

    The left most image shows the scroll bar as you would expect, however the images are then covered as the scroll bar is moved.

    This is my style sheet:

    QScrollBar{
        background-color: rgb(108, 225, 12);
        width: 16px;
        margin: 0;
    }
    
    QScrollBar::handle:vertical{
        background-image: url(:/bar-handle.png);
        margin: 16 0 16 0;
    }
    
    QScrollBar::add-line{
    
        background-image: url(:/bbottom);
        height: 16px;
    
        subcontrol-position:bottom;
        subcontrol-origin: margin;
    
    }
    
    QScrollBar::sub-line{
    
        image: url(:/bar-end.png);
        height: 16px;
    
        subcontrol-position: top;
        subcontrol-origin: margin;
    }
    

    How do i get it to have normal scroll bar behaviour, where the buttons are always shown at the top and bottom and the handle does not have shading above and below it?

    Thank you very much for any of your help,

    Mat

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

      Hi and welcome
      I think you might need to set margin for inner area
      The following works for me with 32x32 images for the ends

      /*inner area*/
      QScrollBar::vertical  {
           border: 1px solid #a5a5a5;
           background: none;
           width: 65px;
           margin: 42px 0 42px 0; /* match top/lower area*/
       }
      
      /*the knob*/
       QScrollBar::handle:vertical {
           background: #d5d5d5;;
       	 border: 2px solid #000000;
           min-height: 60px;	
      	 border-radius: 12px;
       }
      
      /*lower arrow area*/
       QScrollBar::add-line:vertical {
           border: 0px solid grey;
           background: NONE;
           height: 40px;
           subcontrol-position: bottom;
           subcontrol-origin: margin;
       }
      
      /*top arrow area*/
       QScrollBar::sub-line:vertical {
           border: 0px solid grey;
           background: none;
           height: 40px;
           subcontrol-position: top;
           subcontrol-origin: margin;
       }
      
      /*arrows*/
       QScrollBar::up-arrow:vertical  {
      	 image:  url(:/GFX/sbar/up_arrow_scrollbar.png);
      }
      /*pressed*/
      QScrollBar::up-arrow:vertical::pressed  {
      	 image:  url(:/GFX/sbar/up_arrow_scrollbar_pressed.png);
      }
      
      QScrollBar::down-arrow:vertical::pressed  {
      	 image:  url(:/GFX/sbar/down_arrow_scrollbar_pressed.png);
      }
      
      QScrollBar::down-arrow:vertical {
          /* border: 2px solid grey;
           width: 3px;
           height: 23px;  */
      	 image:  url(:/GFX/sbar/down_arrow_scrollbar.png);
       }
      
       QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
           background: none;
       }
      
      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