qt scrollArea设置滑块不隐身
时间: 2023-05-28 11:04:01 浏览: 73
您可以通过设置滑块的持续时间来防止其自动隐藏。可以使用`QScrollBar`的`setSingleStep()`函数设置持续时间。例如:
```python
my_scroll_area.verticalScrollBar().setSingleStep(0)
```
这将使滑块一直可见,直到用户将鼠标移开。如果您想要滑块直接一直可见,您可以使用`setScrollBarPolicy()`函数:
```python
my_scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
```
这将使滑块永远可见,即使内容不足以填满滚动区域。
相关问题
QT ScrollArea
QT ScrollArea is a widget in the QT framework that allows the user to scroll through the contents of a widget that is larger than the available screen space. It is used to display large amounts of data that cannot fit in a single screen or to provide a zooming feature to an application.
The QT ScrollArea widget provides a scroll bar that can be used to navigate through the contents of the widget. It can be used with any widget that inherits from the QWidget class, such as QLabel, QTextEdit, and QTableWidget.
To use the QT ScrollArea widget, you need to create an instance of the QScrollArea class and set the widget that you want to display in it using the setWidget() method. You can also set the viewport margins, scroll bar policies, and other properties of the scroll area.
The QT ScrollArea widget is highly customizable and can be used to create complex user interfaces. You can add custom widgets to the scroll area, set different background colors, and add borders and margins to the widget.
Overall, the QT ScrollArea widget is a powerful tool for creating user interfaces that require scrolling or zooming features. Its ease of use and flexibility make it a popular choice among developers who use the QT framework.
qt scroll area
Qt Scroll Area是一个用于容纳大量内容并提供滚动功能的小部件。要控制滚动条何时出现,可以使用QScrollBar类的setValue函数来设置滚动到的位置,并使用value函数获取当前位置。另外,可以使用ensureVisible和ensureWidgetVisible函数来确保内容可见。默认情况下,滚动条的显示方式为Qt::ScrollBarAsNeeded,即根据需要自动显示或隐藏滚动条。如果需要更多的控制,可以直接获取水平滚动条和垂直滚动条来进行设置。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)