-----BEGIN PGP SIGNED MESSAGE-----
On 05/11/2010 03:33 AM, Malyushytsky, Alex wrote:
> It is not clear what you want to do to me so I would try to clarify what is
> happening in your case in hope it will help you.
>>> And now my QPushButton takes focus , how should i make my scene get focus
>>> now ?
> The scene already has a focus and the focus item is leaveButton widget.
> Look at QGraphicsScene::setFocus help:
> "void QGraphicsScene::setFocus ( Qt::FocusReason focusReason =
> Qt::OtherFocusReason )
> Sets focus on the scene by sending a QFocusEvent to the scene, passing
> focusReason as the reason. If the scene regains focus after having previously
> lost it while an item had focus, the last focus item will receive focus with
> focusReason as the reason.
> If the scene already has focus, this function does nothing."
> If you want move focus to another item you can use
> void QGraphicsScene::setFocusItem ( QGraphicsItem * item, Qt::FocusReason
> focusReason = Qt::OtherFocusReason )
Cuz my parent Widget is QGraphicsView based , so i'd try with this later
> If you don't want leaveButton have focus ever, use
> setFocusPolicy ( Qt::FocusPolicy policy ) // Setting Qt::NoFocus on a widget
> will clear the ItemIsFocusable flag
> QGraphicsProxyWidget * w = QGraphicsScene::addWidget ( QWidget * widget,
> Qt::WindowFlags wFlags = 0 )
> Important! At the first glance I would expect compiler error in
It's scene->addWidget(leaveBtn) instead ;-)
> In my Qt version addItem is declared as :
> void QGraphicsScene::addItem ( QGraphicsItem * item )
> leaveButton is instance of QPushButton and QPushButton is not derived from
> I would expect to see addWidget instead.
Yeah , it's called FocusPolicy , i tried to setFocusPolicy(Qt::NoFocus)
on QPushButton and it works.
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
Qt-interest mailing list