Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Setting slider width in QScrollBar



  • Hello,

    i am using Qt Creator 4.5.2 (Qt 5.9.5) and want to change the width of the slider in a vertical QScrollBar (QScrollArea), because of the narrow design (5 px). So, i played around with parameters verticalScrollBar()->setFixedWidth(40) / verticalScrollBar()->setMinimum(40) / verticalScrollBar()->setMaximum(40) / verticalScrollBar()->setStyleSheet("QScrollBar::vertical{width:40px;}") but nothing worked.

    I can change the slider length, but not the width. What am i doing wrong?



  • add margins to the handle in the stylesheet
    "QScrollBar::handle:vertical{border: none; margin: *px *px *px *px; }"



  • Thank you, that works. But is there a way without stylesheets, because it does affect other visual parameters too and i do not know how to avoid that?


Log in to reply