Discussion:
QComboBox with history
Filip Gruszczyński
2008-07-03 13:13:11 UTC
Permalink
Hello!

I am trying to add history collecting to a QComboBox. I tried
connecting to the signals (activated, currentIndexChanged), but that's
not enough, since I can't control in what order this signal is servied
by other listeners. This is especially a problem, since other object
needs recent history in a slot and I can't get the proper values.
Therefore I need to add
new information to the history earlier - but I have no idea, how to do
it. Anyone knows, which method should I override? I checked class
refference, but found nothing.
--
Filip Gruszczyński
simone
2008-07-03 14:12:51 UTC
Permalink
Post by Filip Gruszczyński
Therefore I need to add
new information to the history earlier - but I have no idea, how to do
it. Anyone knows, which method should I override? I checked class
refference, but found nothing.
For example, you can use userData attribute in the addItem() method or
the setItemData() method to store the information needed and the
findData method to find an item or an index with needed data. More
information on the QComboBox Class Reference.

--
Simone
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
Filip Gruszczyński
2008-07-03 15:26:38 UTC
Permalink
For example, you can use userData attribute in the addItem() method or the
setItemData() method to store the information needed and the findData method
to find an item or an index with needed data. More information on the
QComboBox Class Reference.
I don't think it solves my problem. What I want (need) to do, is add
history of user's choices. Say, there are values a, b and c in the
combo box. First user chooses a, but then changes to c. I would like
to store this information and be able to retrieve whole (or part) of
the history - e.g. [ a, c ].

Therefore I need to intercept the event when user chooses new option
in the combo box, add information to the history and then let the rest
happen (like emitting signals). I can't just intercept a signal,
because I have no control over order of interception.
--
Filip Gruszczyński
Filip Gruszczyński
2008-07-03 15:42:39 UTC
Permalink
Oh, and I could just override hidePopup() but that's just not the
right place. It should be in just the place, where user hits
enter/left key and new option in the combo box is chosen.

But I will use hidePopup() unless I find something better :-/
Post by Filip Gruszczyński
For example, you can use userData attribute in the addItem() method or the
setItemData() method to store the information needed and the findData method
to find an item or an index with needed data. More information on the
QComboBox Class Reference.
I don't think it solves my problem. What I want (need) to do, is add
history of user's choices. Say, there are values a, b and c in the
combo box. First user chooses a, but then changes to c. I would like
to store this information and be able to retrieve whole (or part) of
the history - e.g. [ a, c ].
Therefore I need to intercept the event when user chooses new option
in the combo box, add information to the history and then let the rest
happen (like emitting signals). I can't just intercept a signal,
because I have no control over order of interception.
--
Filip Gruszczyński
--
Filip Gruszczyński
simone
2008-07-03 16:02:09 UTC
Permalink
Post by Filip Gruszczyński
Therefore I need to intercept the event when user chooses new option
in the combo box, add information to the history and then let the rest
happen (like emitting signals). I can't just intercept a signal,
because I have no control over order of interception.
Sorry, I don't understand correctly your desire... :)

When the index changed I normally connect the currentIndexChanged to the
function needed.

Some code:

self.connect(self.ComboBox, SIGNAL("currentIndexChanged(int)"),

self.onIndexChanged)

def onIndexChanged(self, index):
print self.ComboBox.itemData(index).toString()


Normally this works for me... :)

--
Simone
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
Filip Gruszczyński
2008-07-03 22:12:16 UTC
Permalink
Post by simone
Sorry, I don't understand correctly your desire... :)
I want ComboBox to keep history of user's choices and allow access to
this history at any point with up to date information.
--
Filip Gruszczyński
Loading...