views:

749

answers:

1

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?

+4  A: 

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.

jcoon
+1 for the change due to order of actions (and the activated() signal too). Unless directedition is programming some sort of right-to-left UI? I wonder if other cultures do that.
Chris Cameron
@Chris Cameron, Qt can automatically mirror the layout for RTL locales. To test this yourself, just pass the "-reverse" switch on the command line to any Qt application.
Parker