Pyqt - QMenu dynamically populated and clicked
Posted
by
mleep
on Stack Overflow
See other posts from Stack Overflow
or by mleep
Published on 2009-09-23T07:53:24Z
Indexed on
2011/01/16
3:54 UTC
Read the original article
Hit count: 240
I need to be able to know what item I've clicked in a dynamically generated menu system. I only want to know what I've clicked on, even if it's simply a string representation.
def populateShotInfoMenus(self):
self.menuFilms = QMenu()
films = self.getList()
for film in films:
menuItem_Film = self.menuFilms.addAction(film)
self.connect(menuItem_Film, SIGNAL('triggered()'), self.onFilmSet)
self.menuFilms.addAction(menuItem_Film)
def onFilmRightClick(self, value):
self.menuFilms.exec_(self.group1_inputFilm.mapToGlobal(value))
def onFilmSet(self, value):
print 'Menu Clicked ', value
© Stack Overflow or respective owner