首页 技术 正文
技术 2022年11月17日
0 收藏 847 点赞 3,952 浏览 4795 个字

# 过滤鼠标滚轮事件

class stepItem(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.init_ui()
self.init_ui_data() def init_ui(self):
self.setObjectName('scriptManager')
self.ui = stepItem_ui.Ui_stepItem()
self.ui.setupUi(self)
self.ui.comboBox_type.setStyleSheet("QComboBox QAbstractItemView::item{height:25px;}")
self.ui.comboBox_type.setView(QListView())
self.ui.comboBox_relyon.clear() self.ui.textEdit_step_result.clear()
self.ui.textEdit_step_result.adjustSize() self.connect(self.ui.comboBox_type, SIGNAL('currentIndexChanged(int)'), self.currentIndexChanged) # 过滤鼠标滚轮事件
self.ui.comboBox_type.installEventFilter(self)
self.ui.comboBox_relyon.installEventFilter(self) def eventFilter(self, source, event):
if source == self.ui.comboBox_type:
if event.type() == QEvent.Wheel:
return True
if source == self.ui.comboBox_relyon:
if event.type() == QEvent.Wheel:
return True return QWidget.eventFilter(self, source, event) def init_ui_data(self):
self.get_res(gl.gl_data["SET_STEP_RES"], None) def get_res(self, data, param):
'''
获取步骤资源
:param data:
:return:
''' if data.has_key("DATA"):
self.ui.comboBox_type.clear()
self.ui.comboBox_type.addItem('', 0)
list_res = data["DATA"]
for res in list_res:
self.ui.comboBox_type.addItem(res['S_STEP_TYPE_NAME'], res['I_STEP_TYPE_ID'])
# self.ui.comboBox_type.setItemData(res['I_STEP_TYPE_ID'], res['I_STEP_TYPE_ID'])
# self.ui.comboBox_type.setCurrentIndex(0) def setStepData(self, stepNum, stepType, stepValue):
# self.ui.label_step.setText(stepNum)
# self.ui.comboBox_type.setCurrentIndex(self.ui.comboBox_type.findText(stepType))
# self.ui.lineEdit.setText(stepValue)
pass def currentIndexChanged(self):
#text = self.ui.comboBox_type.currentText().toUtf8().data()
step_index = self.ui.comboBox_type.currentIndex()
# aa = self.ui.comboBox_type.itemData(id).toInt()
step_name = self.ui.comboBox_type.itemText(step_index)
step_id = self.ui.comboBox_type.itemData(step_index) self.ui.lineEdit.setReadOnly(False)
if step_id == 3 or step_id == 9 or step_id == 10 or step_id == 13:
if len(self.ui.lineEdit.text()) == 0:
self.ui.lineEdit.setText(QString(u'该选项不需要参数!'))
self.ui.lineEdit.setReadOnly(True)
else:
if self.ui.lineEdit.text() == QString(u'该选项不需要参数!'):
self.ui.lineEdit.clear()
self.ui.lineEdit.setReadOnly(False)
self.ui.lineEdit.setFocus() # print textif __name__ == '__main__':
import sys
app = QApplication(sys.argv)
myQWidget = stepItem()
myQWidget.show()
# myQWidget.test()
sys.exit(app.exec_())所有事件记录:
AccessibilityDescription = 130
AccessibilityHelp = 119
AccessibilityPrepare = 86
ActionAdded = 114
ActionChanged = 113
ActionRemoved = 115
ActivationChange = 99
ApplicationActivate = 121
ApplicationActivated = 121
ApplicationDeactivate = 122
ApplicationDeactivated = 122
ApplicationFontChange = 36
ApplicationLayoutDirectionChange = 37
ApplicationPaletteChange = 38
ApplicationWindowIconChange = 35
ChildAdded = 68
ChildPolished = 69
ChildRemoved = 71
Clipboard = 40
Close = 19
CloseSoftwareInputPanel = 200
ContentsRectChange = 178
ContextMenu = 82
CursorChange = 183
DeferredDelete = 52
DragEnter = 60
DragLeave = 62
DragMove = 61
Drop = 63
DynamicPropertyChange = 170
EnabledChange = 98
Enter = 10
EnterWhatsThisMode = 124
FileOpen = 116
FocusIn = 8
FocusOut = 9
FontChange = 97
Gesture = 198
GestureOverride = 202
GrabKeyboard = 188
GrabMouse = 186
GraphicsSceneContextMenu = 159
GraphicsSceneDragEnter = 164
GraphicsSceneDragLeave = 166
GraphicsSceneDragMove = 165
GraphicsSceneDrop = 167
GraphicsSceneHelp = 163
GraphicsSceneHoverEnter = 160
GraphicsSceneHoverLeave = 162
GraphicsSceneHoverMove = 161
GraphicsSceneMouseDoubleClick = 158
GraphicsSceneMouseMove = 155
GraphicsSceneMousePress = 156
GraphicsSceneMouseRelease = 157
GraphicsSceneMove = 182
GraphicsSceneResize = 181
GraphicsSceneWheel = 168
Hide = 18
HideToParent = 27
HoverEnter = 127
HoverLeave = 128
HoverMove = 129
IconDrag = 96
IconTextChange = 101
InputMethod = 83
KeyboardLayoutChange = 169
KeyPress = 6
KeyRelease = 7
LanguageChange = 89
LayoutDirectionChange = 90
LayoutRequest = 76
Leave = 11
LeaveWhatsThisMode = 125
LocaleChange = 88
MacSizeChange = 177
MaxUser = 65535
MenubarUpdated = 153
MetaCall = 43
ModifiedChange = 102
MouseButtonDblClick = 4
MouseButtonPress = 2
MouseButtonRelease = 3
MouseMove = 5
MouseTrackingChange = 109
Move = 13
NonClientAreaMouseButtonDblClick = 176
NonClientAreaMouseButtonPress = 174
NonClientAreaMouseButtonRelease = 175
NonClientAreaMouseMove = 173
None = 0
OkRequest = 94
Paint = 12
PaletteChange = 39
ParentAboutToChange = 131
ParentChange = 21
PlatformPanel = 212
Polish = 75
PolishRequest = 74
QueryWhatsThis = 123
RequestSoftwareInputPanel = 199
Resize = 14
Shortcut = 117
ShortcutOverride = 51
Show = 17
ShowToParent = 26
SockAct = 50
StateMachineSignal = 192
StateMachineWrapped = 193
StatusTip = 112
StyleChange = 100
TabletEnterProximity = 171
TabletLeaveProximity = 172
TabletMove = 87
TabletPress = 92
TabletRelease = 93
Timer = 1
ToolBarChange = 120
ToolTip = 110
ToolTipChange = 184
TouchBegin = 194
TouchEnd = 196
TouchUpdate = 195
UngrabKeyboard = 189
UngrabMouse = 187
UpdateLater = 78
UpdateRequest = 77
User = 1000
WhatsThis = 111
WhatsThisClicked = 118
Wheel = 31
WindowActivate = 24
WindowBlocked = 103
WindowDeactivate = 25
WindowIconChange = 34
WindowStateChange = 105
WindowTitleChange = 33
WindowUnblocked = 104
WinEventAct = 132
WinIdChange = 203
ZOrderChange = 126

    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918