directedition directedition - 2 months ago 16
Python Question

PyQT combobox only react on user interaction

I have a listbox that you can select users in. To the left of that is a combobox listing the available groups the user can be put it. If the user is in a group, the combobox will automatically be set to that group. I want to make it so when you change the group selection, it will move the user to that group. I added this connection:

QtCore.QObject.connect(self.GroupsBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.HandleGrouping)

The problem is that since I'll be selecting different users in different groups, every time I select a new user, the default option in the combobox changes and Qt registers this as a 'currentIndexChanged' signal.

There appears to be no way to only fire the signal on direct user-interaction with the widget itself. What methods can I use to work around this?


Catch a signal from the QComboBox (activated(int index)), and update the selected user based on that. In you Handler function, don't do anything if the selected index in the combobox is the same as the group the selected user is in.

Maybe move your combobox to the right of the user listbox, as your order of actions will be Select User --> Select Group.