[PyQt] action group triggered signals

Phil Thompson phil at riverbankcomputing.com
Wed Jan 26 19:48:16 GMT 2011


On Wed, 26 Jan 2011 11:24:28 -0800, Scott Frankel <frankel at circlesfx.com>
wrote:
> Hi all,
> 
> What's the best way to connect an action group triggered signal?  The  
> following isn't working:
> 
> 	self.connect(self.theActGroup, QtCore.SIGNAL("triggered(action)"),  
> self.foo)
> 
> 
> 
> I'm adding a QToolButton with mutually exclusive actions to a  
> QToolBar.  I must be missing something obvious, since the method I  
> connect to the triggered signal is not executing.  eg:
> 
> 	self.theButton          = QtGui.QToolButton()
> 	self.theButton.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
> 	self.theActGroup  = QtGui.QActionGroup(self.theButton)
> 	self.theActGroup.setExclusive(True)
> 	# actions added here...
> 
> 	self.connect(self.theActGroup, QtCore.SIGNAL("triggered(action)"),  
> self.foo)
> 	# self.foo() not executed
> 
> See attached file for simple, working example.
> 
> Thanks!
> Scott

The signal signature is "triggered(QAction *)".

If you used new-style connections you wouldn't have to worry about this.

Phil


More information about the PyQt mailing list