pyqt pyside qcombobox disable wheel scrolling

pyqt pyside qcombobox disable wheel scrolling

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_())

After this, when the use of the key qcombobox rollers will not change the current value of the

Guess you like

Origin www.cnblogs.com/ibingshan/p/11454559.html