【发布时间】:2012-03-17 13:27:25
【问题描述】:
我试图在 PyQT 中找出如何设置鼠标滚轮事件? 我需要它,所以我可以将它附加到 Qscroll 区域
我使用的代码运行良好。但大小是硬编码的。我需要它以某种方式根据滚轮(在鼠标上)的使用方式进行动态调整。就像我向上滑动鼠标滚轮时一样。我的框架的高度会扩展(例如每刻度 50 像素),反之亦然。
self.scrollArea = QtGui.QScrollArea()
#set the parent of scrollArea on the frame object of the computers
self.scrollArea.setWidget(self.ui.Main_Body)
self.scrollArea.setWidgetResizable(True)
#add the verticalLayout a object on PYQT Designer (vlayout is the name)
#drag the frame object of the computers inside the verticalLayout
#adjust the size of the verticalLayout inside the size of the frame
#add the scrollArea sa verticalLayout
self.ui.verticalLayout.addWidget(self.scrollArea)
self.ui.Main_Body.setMinimumSize(400, 14000)
最后一部分是我想要增强的。我不希望它被硬编码为 14000 值。 感谢任何会提供帮助的人。我希望给定的示例代码也可以帮助其他有需要的人。
)
【问题讨论】:
标签: python scroll height pyqt4 mousewheel