QScroller 和 QScrollBar 之间的 qt 冲突

Mik*_*haw 2 c++ qt scrollbar qscrollarea

我发现 QScroller 和 QScrollBar 之间存在冲突。所以我有一个带有垂直滚动条的 QScrollArea。我还激活了一个 QScroller,它允许我使用左键单击按钮进行动态滚动。但我不能再抓住滚动条句柄了。因为一旦我抓住它,QScroller 开始接管。这是我添加 QScroller 的方式:

QScroller::grabGesture(mArea, QScroller::LeftMouseButtonGesture) ; 
Run Code Online (Sandbox Code Playgroud)

知道如何解决冲突吗?

小智 6

I've had the same issue. It can be avoided by applying the grabGesture to the viewport of the QScrollArea, instead of the whole widget:

QScroller::grabGesture(mArea->viewport(), QScroller::LeftMouseButtonGesture) ; 
Run Code Online (Sandbox Code Playgroud)