Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Does anyone know how to make a custom scrollbar that looks as follows:



  • I've been messing around with creating my own scrollbar class to make it look like a specific one (I'll attach it). The problem I keep having is that the scroll arrows are only hidden and not removed, so the scrollbar doesn't fully scroll down. I also don't know how to make the scroll area a different color than the rest of the table that it's on. I'll attach the example and the code I have so far.

    Code:

    class CustomScrollBar(QtWidgets.QScrollBar):
    def init(self, *args, **kwargs):
    QtWidgets.QScrollBar.init(self, *args, **kwargs)
    self.baseSheet = '''
    QScrollBar::right-arrow:vertical, QScrollBar::left-arrow:vertical{{
    border: none;
    background: none;
    color: none;
    }}

            QScrollBar::add-line:vertical {{
              border: none;
              background: none;
            }}
    
            QScrollBar::sub-line:vertical {{
              border: none;
              background: none;
            }}
           
          
            '''
       
        self.setStyleSheet(self.baseSheet.format())
    

    Example: https://ibb.co/cT4TbtB



  • @sherief if you go look at the documentation here (https://doc.qt.io/qt-5/classes.html#) and pull up QScrollBar you would find that it inherits from QAbstractSlider which in turn inherits from QWidget.

    So the chances are if you want to create your own QScrollBar you will probably need to use its parent QAbstractSlider or its grand-parent QWidget to implement the things you are attempting to do.

    Note not only does QScrollBar inherit from QAbstractSlider but also QDial and QSlider do as well so if you wanting ideas on how to manipulate the QAbstractSlider perhaps these other two child classes might help you.


  • Lifetime Qt Champion

    Hi
    If you mean for it to have no arrows.
    then something like
    alt text


Log in to reply