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. To lower the scroll handle to the bottom
Qt 6.11 is out! See what's new in the release blog

To lower the scroll handle to the bottom

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 298 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    c8863a8c-149d-42dc-82cb-f6c64242fa75-image.png

    void QCustomScrollBar::paintEvent(QPaintEvent* e)
    {
        QPainter painter1(this);
        QPainter* p = &painter1;
        QStylePainter painter(this);
    
        m_StyleOpt.init(this);
    	m_StyleOpt.subControls = QStyle::SC_ScrollBarAddLine;
    	painter.drawComplexControl(QStyle::CC_ScrollBar, m_StyleOpt);
    
    	m_StyleOpt.subControls = QStyle::SC_ScrollBarSubLine;
    	painter.drawComplexControl(QStyle::CC_ScrollBar, m_StyleOpt);
    
    
    
        m_StyleOpt = QStyleOptionSlider();
        initStyleOption(&m_StyleOpt);
        
        m_StyleOpt.singleStep = 1;		// Slider를 움직이거나 방향키를 눌러 이동할 수 있는 최소값
        m_StyleOpt.pageStep = 10;		// Page up/down 키를 눌렀을 때 이동하는 최소값.
        m_StyleOpt.upsideDown = false;
        //m_StyleOpt.rect.setY(50);
    
        int nMin = this->minimum();
        int nMax = this->maximum();
    
        //QRect rect = style()->subControlRect(QStyle::CC_ScrollBar, &m_StyleOpt, QStyle::SC_ScrollBarSlider);
        QRect rect = style()->subControlRect(QStyle::CC_ScrollBar, &m_StyleOpt, QStyle::SC_ScrollBarSlider);
    
        if (rect.y() <= 50)
            rect.setTop(51);
    
        if (rect.y() >= 228)
            rect.setTop(228);
    
        m_StyleOpt.rect = QRect(rect.topLeft(), QSize(rect.width(), 50));
        //m_StyleOpt.rect = QRect(rect.topLeft(), QSize(rect.width(), 50));
        //m_StyleOpt.rect.setSize(QSize(rect.width(), 50));
    
        style()->drawControl(QStyle::CE_ScrollBarSlider, &m_StyleOpt, p, this);
    	
    }
    

    Is there a way to lower the scroll handle all the way down? I've inserted 12 items into the list widget, and I'm scrolling all the way down, but I want to get rid of the gaps in the yellow arrow in the picture and get to the bottom.

    I want to maintain the handle size and tell me how to lower it to the bottom.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      IknowQT
      wrote on last edited by
      #2

      add Question

      what is QScrollBar::add-line:vertical:pressed

      QScrollBar:vertical { background-color: #002039; width: 50px; margin: 54px 0px 55px 0px; border: none; }\
                  QScrollBar::handle:vertical\
                  {\
                      background-image: url(:/PopRsrc/Common/all-btn-scroll-middle.jpg); min-height: 50px; margin: 0px 0px 0px 0px;\
                  }\
                  QScrollBar::add-line:vertical\
                  {\
                      margin: 4px 0px 1px 0px; height: 50px; width: 50px; subcontrol-position: bottom;\
                      subcontrol-origin: margin; border-image: url(:/PopRsrc/Common/all-btn-scroll-down.jpg); stretch;\
                  }\
                  QScrollBar::sub-line:vertical\
                  {\
                      margin: 1px 0px 4px 0px; height: 50px; width: 50px; subcontrol-position: top; subcontrol-origin: margin;\
                      border-image: url(:/PopRsrc/Common/all-btn-scroll-up.jpg); stretch;\
                  }\
                  QScrollBar::add-page:vertical { background-color: #002039; }\
                  QScrollBar::sub-page:vertical { background-color: #002039; }\
                  QScrollBar::add-line:vertical:pressed\
                  {\
                      margin: 4px 0px 1px 0px; height: 50px; width: 50px; subcontrol-position: bottom;\
                      subcontrol-origin: margin; border-image: url(:/PopRsrc/Common/all-btn-scroll-down-p.jpg); stretch;\
                  }\
                  QScrollBar::sub-line:vertical:pressed\
                  {\
                      margin: 1px 0px 4px 0px; height: 50px; width: 50px; subcontrol-position: top; subcontrol-origin: margin;\
                      border-image: url(:/PopRsrc/Common/all-btn-scroll-up-p.jpg); stretch; }\
                  }"
      
      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        highlight the last row?

        I 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          highlight the last row?

          I Offline
          I Offline
          IknowQT
          wrote on last edited by
          #4

          @JoeCFD

          I want to change the image of when I clicked and when I didn't.

          QScrollBar::add-line:vertical\
                      {\
                          margin: 4px 0px 1px 0px; height: 50px; width: 50px; subcontrol-position: bottom;\
                          subcontrol-origin: margin; border-image: url(:/PopRsrc/Common/all-btn-scroll-down.jpg); stretch;\
                      }\
                      QScrollBar::add-line:vertical:pressed\
                      {\
                          background-color: red\
                      }\
                      QScrollBar::sub-line:vertical\
                      {\
                          margin: 1px 0px 4px 0px; height: 50px; width: 50px; subcontrol-position: top; subcontrol-origin: margin;\
                          border-image: url(:/PopRsrc/Common/all-btn-scroll-up.jpg); stretch;\
                      }\
                      QScrollBar::sub-line:vertical:pressed\
                      {\
                          margin: 1px 0px 4px 0px; height: 50px; width: 50px; subcontrol-position: top; subcontrol-origin: margin;\
                          border-image: url(:/PopRsrc/Common/all-btn-scroll-up-p.jpg); stretch; }\
                      }\
          
          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