[Qt-interest] QGraphicsScene isActive method returns wrong value [SOLVED]
Frederic Tingaud
tingaud at gostai.com
Fri Jul 16 11:37:49 CEST 2010
Le 05/07/2010 11:26, Frederic Tingaud a écrit :
> Hi all,
>
> I have weird behavior with a QGraphicsTextItem in a QGraphicsView. The
> focus cannot be cleared and no focusIn focusOut event occurs since I
> switched from Qt 4.5.2 to Qt 4.6.3, even when setting:
> setTextInteractionFlags(Qt::TextEditorInteraction);
> setFlag(QGraphicsItem::ItemIsFocusable, true);
> I tried to look into the problem and it seems to be due to the fact that
> scene()->isActive() method returns false even though it is active. If I do:
> qDebug()<< scene()->isActive()<<
> scene()->views().first()->isActiveWindow();
> the output is "false true" which should not be possible, if I understand
> the documentation correctly.
> Do any of you have an idea about what could be happening ?
>
> Regards,
>
>
I finally had time to look into this and find out the issue.
My QGraphicsScene receives a QEvent::WindowDeactivate before receiving
QEvent::WindowActivate. It messes up an internal counter in
QGraphicsScene, called activationRefCount, that should change between 0
and 1 and instead changes between -1 and 0, thus never returning true
for isActive(). Actually, I just saw that the bug was already reported
as QTBUG-11148.
The workaround I used is to filter QEvent::WindowDeactivate and discard
it if the scene was not active.
--
-------------------------------------------------------------------------------
Frederic TINGAUD
-------------------------------------------------------------------------------
More information about the Qt-interest-old
mailing list