I have an application where I have a main widget that is controlled by a horizontal QScrollBar. The main widget is quite involved so I can't use a QScrollArea so I am left to using regular a QScrollBar instead. Ultimately I want the scrollbar to show only when I hover on top of the lower part of the main widget, and I want it to show on top of the widget rather than next to it.
The current implementation is something along the lines of:
def __init__(self, parent=None):
self.main_widget = MainWidget(self)
self.box.addWidget(self.canvas)
self.box.addWidget(self.scrollbar)
self.scrollbar.hide()
self.setLayout(self.box)
...
class NestedMainWidget(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.main_widget = MainWidget(self)
self.scrollbar = QScrollBar(Qt.Horizontal, self)
self.box = QVBoxLayout()
self.box.addWidget(self.canvas)
self.box.addWidget(self.scrollbar)
self.scrollbar.hide()
self.setLayout(self.box)
...
To copy to clipboard, switch view to plain text mode
The show/hide logic will then show/hide the scroll bar according to where the mouse position. This works fine. But obviously with this implementation the scroll bar will be shown next to the main widget, i.e., the main widget will be shrunk vertically to show the scroll bar.
How can I have the scroll bar to show on top of the main widget instead?
(The behavior I'm after is the scroll bar hiding that OS X Lion implements btw.)
Bookmarks