PDA

View Full Version : find the item



ensky_cy
2nd December 2009, 05:47
hello,
there are several items in the scene.
when the mouse above one item, how to enlarge the item to full screen.
I want to reimplement the QGraphicsScene::xxxEvent().
I nearly can't move the items.I'm so confused.I want know the scene how to know the item that under my mouse.
I'm a newcomer.Thanks !

aamer4yu
2nd December 2009, 06:56
Did you go through the Qt Demos ?
Have a look Qt Embedded Dialogs under Demonstrations in Qt Demos..you will get an idea.
Also if u want to show an item fullscreen on mouse over, also think of how u want to get back to normal view again..

zgulser
2nd December 2009, 07:06
you just need to reimplement mouseMoveEvent() or hoverEnterEvent(). But don't forget to put setAcceptHoverEvents(true) in order to implement your custom things when the cursor is on the item.

ensky_cy
2nd December 2009, 07:43
Thanks all.
embeded demo is about QGraphicsProxywidget.there is only QGraphicsItem,QGraphicsItem doesn't have signal and slot,it's hard to bring out animate.If I reimplement QGraphicsItem's fuctions,how to program them(eg.hoverLeaveEvent).
scale()fuction,it isn't work.
Thanks !

scascio
2nd December 2009, 08:52
hello,
when the mouse above one item, how to enlarge the item to full screen.


What do you mean by that? Changing item position and size? are you sure?

I see two points:
1. When the item need to be enlarged and reduced?
Either you listen to mouse move of the view(or scene) or the item. Not same thing in design since the second one need a link from your item to object processor that will enlarge it.

2.Enlarge and reduce Item
Lots of way to do it. Your approach is to change the scene. But then the hoverLeave will be trigger on modified item that is bigger and not for real coordinates of the scene.
You can also use a unique top level item whose content is changed depending on item hovered by mouse. Or you can add an overlapped view with a copy of the item displayed at another scale but it is tricky.