import sys from PyQt5 import QtCore, QtWidgets import xxx as ui # xxx is your ui py fide class MainWindow(QtWidgets.QMainWindow, ui): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setupUi(self) self.test_combobox.installEventFilter(self) def eventFilter(self, widget, event): if event.type() == QtCore.QEvent.Wheel and widget == test_combobox: return True return super(MainWindow, self).eventFilter(source, event) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) w = MainWindow() w.show() sys.exit(app.exec_())
這樣以後,qcombobox 使用中鍵滾輪的時候就不會再改變當前值了app