平滑滚动 QTableWidget [英] Scrolling QTableWidget smoothly
问题描述
我有一个带有自定义小部件的 QTableWidget.这些小部件很大,几乎占据了整个滚动区域的高度,因此只有一行是可见的.
I have a QTableWidget with custom Widgets. These widgets are big and fill almost the whole scroll area in height, so that only one row is visible.
我可以用鼠标滚轮或通过拖动滚动条来滚动,但行总是跳转.
I can scroll with the mouse wheel or by dragging the scroll bar, but the row always jumps.
有没有办法把QTableWidget配置成平滑滚动,不跳转?
Is there a way to configure the QTableWidget to smoothly scroll, without jumping?
推荐答案
尝试使用这个:
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel)
来自 Qt 文档:
enum ScrollMode { ScrollPerItem, ScrollPerPixel }
enum ScrollMode { ScrollPerItem, ScrollPerPixel }
verticalScrollMode : ScrollMode
verticalScrollMode : ScrollMode
此属性保存视图如何在垂直方向滚动其内容方向.
This property holds how the view scrolls its contents in the vertical direction.
此属性控制视图如何垂直滚动其内容.可以按像素或按项目滚动.
This property controls how the view scroll its contents vertically. Scrolling can be done either per pixel or per item.
这篇关于平滑滚动 QTableWidget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!