Dropdown event / callback in combo box in pyqt4

is there a callback or event for a dropdown in a pyqt4 combo box? As well asself.connect(self.ui.combobox,SIGNAL("activated(int)"),self.refresh

+2
source share
2 answers

QCombobox uses QAbstractItemView (QListView by default) to display dropdown items (accessible through a property view()). I do not know a single signal for this purpose.

But you can set eventFilter to do the trick using installEventFiltercombobox in the view and implementing the eventFiltermethod:

from PyQt4 import QtCore, QtGui
class ShowEventFilter(QtCore.QObject):
    def eventFilter(self, filteredObj, event):
        if event.type() == QtCore.QEvent.Show:
            print "Popup Showed !"
            # do whatever you want
        return QtCore.QObject.eventFilter(self, filteredObj, event)

if __name__ == '__main__':
    app = QtGui.QApplication([])
    cb = QtGui.QComboBox()
    cb.addItems(['a', 'b', 'c'])

    eventFilter = ShowEventFilter()
    cb.view().installEventFilter(eventFilter)
    cb.show()
    app.exec_()
+2
source

Perhaps you could try

customContextMenuRequested(const QPoint &pos) 

(inherited from QWidget)?

0
source

All Articles