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

QScrollBar and handle height

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 9.3k Views 1 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
    stima_ua
    wrote on last edited by
    #1

    I can not set handle height. My css:
    @
    QScrollBar:vertical {
    border-image: url(:/images/scroll_bg.png);
    width: 20px;
    margin: 5px 5px 52px 0px;
    }

    QScrollBar::handle:vertical {
    background: url(:/images/handle.png);
    height: 5px;
    width: 5px;
    /border-radius: 3px;/
    }

    QScrollBar::add-page:vertical {
    border-image: url(:/images/scroll_add_page.png);
    }

    QScrollBar::sub-page:vertical {
    margin: 5px 2px 0px 2px;
    border-image: url(:/images/scroll_sub_page.png);
    }

    QScrollBar::add-line:vertical {
    border-image: url(:/images/add_line.png);
    height: 26px;
    margin: 0px 5px 5px 0px;
    subcontrol-origin: margin;
    }

    QScrollBar::sub-line:verticall {
    border-image: url(:/images/sub_line.png);
    height: 26px;
    margin: 0px 5px 26px 0px;
    subcontrol-position: bottom;
    subcontrol-origin: margin;
    }

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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stima_ua
      wrote on last edited by
      #2

      mmm...
      How can I get handle from scrollbar to set him fixed size

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        The main idea of the handle height is that it's height represents a percentage of the total height it is scrolling on.

        Eg if the actual size is twice the scroll area then the handle height would be half the visible area.

        Why would you want to change this behaviour? What is your specific use case?

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          I agree with Eddy, changing the default behavior of a scroll bar can confuse the user. However I would try to change values into the "QStyleOptionSlider":http://doc.qt.nokia.com/latest/qstyleoptionslider.html#details to see if this trick works for drawing the scroll bar. It is just an idea.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stima_ua
            wrote on last edited by
            #5

            thnx but i dont know how :(

            @void TreeWidget::paintEvent(QPaintEvent *event)
            {
            QTreeWidget::paintEvent(event);
            QPainter painter(this);
            QStyleOptionSlider option;

            option.initFrom(this);
            
            /*????*/
            
            style()->drawComplexControl(QStyle::CC_Slider, &option, &painter, this);
            

            }@

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6

              Just a thought: why not use a "QSlider":http://doc.qt.nokia.com/4.8-snapshot/qslider.html#details?

              Sounds this is what you want and you can use stylesheet to change the look of the handle.

              Qt Certified Specialist
              www.edalsolutions.be

              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