View Full Version : QGraphicsItem-QGraphicsScene
hgedek
4th August 2007, 11:23
I created a form using QGraphics classes.On them there are pictures.How can I scale them by using keyboard ?
(For scaling I am using QTimeLine class -scale() function etc.)
marcel
4th August 2007, 11:41
If you want to scale only the selected image( that item has to have the selectable flag ), independently of the other images, then you can catch keyboard event with QGraphicsItem::keyPressEvent.
If you want to scale the entire scene at the same time, then you can catch key presses with QGraphicsScene::keyPressEvent.
Please note that you have to subclass QGraphicsItem/QGraphicsScene and override keyPressEvent in order to be able to get key presses.
Regards
hgedek
4th August 2007, 11:49
I think I will use QGraphicsItem.On scene I have 6 image.And using keyboard I will pass one to another.Then pressed anothet button I will activate it.(Like Nokia menu!)
marcel
4th August 2007, 11:54
:)
To move with the keyboard from one item to another in a scene you will have to override QGraphicsScene::keyPressEvent and catch the arrow key presses there.
The default behavior for the arrow keys is none( the view will scroll actually ).
Regards
hgedek
4th August 2007, 12:27
Ok.I read scene::keyPressEvent.But I couldnt understand how to do.setFocus or setFocusItem
functions are used?Or how to do?
infos:
items are scaling translating etc in its Item class.This works by hover event.
marcel
4th August 2007, 12:35
I think QGraphicsItem::setSelected(true) should do it.
But, anyway, if the next item that you select does not have focus, you also should call setFocusItem. Make sure that all the items have the flags: ItemIsSelectable and ItemIsFocusable.
Regards
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.