Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, September 2007
QActionGroup::checkedAction() question


Message 1 in thread

Hello,

I am playing around a bit with Qt-4.3 and QActionGroup. That is,
dynamically adding and removing actions from a group. My observation
is that groups remember checked actions even if it they are removed from
a group. I wonder if this is intentional?

I Hope some lines of Python code are not inappropriate here:


import sys
from PyQt4 import QtGui, QtGui

app = QtGui.QApplication(sys.argv)
group = QtGui.QActionGroup(None)
action = QtGui.QAction('test', group)

group.addAction(action)
action.setCheckable(True)
print group.checkedAction() is None
#>> True

action.setChecked(True)
group.removeAction(action)
print group.checkedAction() is action
#>> True



Jürgen








 

--
 [ signature omitted ] 

Message 2 in thread

Juergen Urner wrote:
> Hello,
> 
> I am playing around a bit with Qt-4.3 and QActionGroup. That is,
> dynamically adding and removing actions from a group. My observation
> is that groups remember checked actions even if it they are removed from
> a group. I wonder if this is intentional?
> 
> I Hope some lines of Python code are not inappropriate here:
> 
> 
> import sys
> from PyQt4 import QtGui, QtGui
> 
> app = QtGui.QApplication(sys.argv)
> group = QtGui.QActionGroup(None)
> action = QtGui.QAction('test', group)
> 
> group.addAction(action)
> action.setCheckable(True)
> print group.checkedAction() is None
> #>> True
> 
> action.setChecked(True)
> group.removeAction(action)
> print group.checkedAction() is action
> #>> True
> 

Looks like a bug - A quick look at the code suggests that 
QActionGroup::removeAction does not clear d->current. Can you please 
report this bug to qt-bugs@xxxxxxxxxxxxx so we can look into this further?

Thanks,
Girish

--
 [ signature omitted ]