简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM