[Qt-interest] Find main window from widget
Cole, Derek
dcole at integrity-apps.com
Sun Jan 23 06:32:31 CET 2011
Thank you..not long after I posted to the group I found a version of this on a forum and was able to adapt it to my situation. The only hitch is, that QGraphicsItem has to subclass QWidget, and that has to be first in the list of items your QGraphicsItem subclasses (I was actually subclassing QGraphicsPixmapItem)
-----Original Message-----
From: yunqiu liu [mailto:yunqiuliu at yahoo.com]
Sent: Sat 1/22/2011 4:21 PM
To: Cole, Derek; qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Find main window from widget
Hi Derek,
you could try,
1, declare a signal function in subclass of QGraphicsItem
For example, in subclass "sGraphicsItem",
signals:
void pos_hoverMoveEvent_signal(int,int);
2, in function sGraphicItem::hoverMoveEvent ( QGraphicsSceneHoverEvent * event )
get x and y position
emit pos_hoverMoveEvent_signal(x,y);
3, try to build the connect of signal and slot callback function between two
objects(graphicsitem and label)
Thanks,
YQ
________________________________
From: "Cole, Derek" <dcole at integrity-apps.com>
To: qt-interest at qt.nokia.com
Sent: Sat, January 22, 2011 9:34:56 AM
Subject: [Qt-interest] Find main window from widget
Find main window from widget
Hello,
If I have subclass a QGraphicsItem, and I want to send some information from the
hoverMoveEvent back to a label that is in my main UI, how do I get that? Do I
just loop over event.widget().parentWidget() until that returns zero, and then I
can try to do a findChild<QLabel *>(labelName)?
I thought there would be an easy way to find another widget from within one, but
its not popping out at me anyway.
I basically want a label to update with my pixel coordinates as I mouse over
this QGraphicsItem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110123/3a95fa17/attachment.html
More information about the Qt-interest-old
mailing list