Hyun-geun Kim
Hyun-geun Kim

Reputation: 1069

PyQt4 : Can I intercept the currentIndexChanged signal of QComboBox?

I build up a UI consisted of QComboBox and QGraphicsScene and it's QGraphicsItems.

When I change the index of QComboBox, refresh QGraphicsScene so it set to default. To solve it, I store a geometry info to a node. It works well.

At this time, I want to determine that QGraphicsItems are modified, and their geo-infos are not stored. So, UI notice to user that he or she have to store them.

I want that it happens when change QComboBox, and to do that I have to intercept the currentIndexChanged signal. It means that before QComboBox change the index actually, it read the flag and do something to user, and not to miss the geo-infos QComboBox return to previous index.

Upvotes: 0

Views: 1440

Answers (1)

ekhumoro
ekhumoro

Reputation: 120798

Your question is a little hard to understand.

Do you want to know the previous index before the current index changes? If so, then keep a record of the previous index:

def __init__(self):
    self._previous_index = -1

def handleCurrentIndexChanged(self, index):
    # do stuff with previous_index (if valid)
    ...
    self._previous_index = index

Upvotes: 1

Related Questions