API 浏览器
滚动区域

QScrollArea 组件提供了一种通过封装内容来自定义滚动条的简洁方法。将其视为一个具有 overflow: auto 的 DOM 元素,但具有你自定义样式的滚动条(而不是浏览器默认的滚动条),并在顶部添加了一些不错的功能。

¥The QScrollArea component offers a neat way of customizing the scrollbars by encapsulating your content. Think of it as a DOM element which has overflow: auto, but with your own custom styled scrollbar instead of browser’s default one and a few nice features on top.

Loading QScrollArea API...

用法(Usage)

¥Usage

以下示例最好在桌面设备上查看,因为它们在移动设备上意义不大。

¥The following examples are best seen on desktop as they make too little sense on a mobile device.

提示

你还可以查看 布局抽屉 以查看更多实际示例。

¥You can also take a look at Layout Drawer to see some more examples of it in action.

基本(Basic)

¥Basic

Vertical content



Horizontal content



Vertical and horizontal content



样式化(Styled)

¥Styled

Styled thumb and bar



Styled



暗黑设计(Dark design)

¥Dark design

Force dark mode



控制滚动条可见性(Controlling scrollbar visibility)

¥Controlling scrollbar visibility

使用 visible 布尔属性时,默认的鼠标悬停/离开行为将被禁用,你可以完全控制滚动条的可见性。

¥When using the visible Boolean prop, the default mouse over/leave behavior is disabled, leaving you in full control of the scrollbar visibility.

Controlling scrollbar visibility



延迟(Delay)

¥Delay

当内容发生变化时,滚动条会出现,然后再次消失。你可以设置滚动条再次消失前的延迟时间(以毫秒为单位)(如果组件未悬停):

¥When content changes, the scrollbar appears then disappears again. You can set a certain delay (amount of time in milliseconds) before scrollbar disappears again (if component is not hovered):

Delay



滚动位置(Scroll position)

¥Scroll position

Scroll Position



滚动事件(Scroll event)

¥Scroll event

以下是使用 @scroll 事件同步两个容器之间滚动的示例。

¥Below is an example of using the @scroll event to synchronize the scrolling between two containers.

Synchronized