Basically using addWidget instead of addItem is good thing, but in this case the object is already made, so no need to use it. Documentation tells more about it: http://doc.qt.nokia.com/latest/qgraphicsscene.html#addWidget
addItem() takes QGraphicsWidget as parameter. This is strange, since official Qt API returns pointer to QGraphicsItem... QGraphicsItemInterface seems to be some kind of wrapper to handle different kinds of QGraphicsItems, including QGraphicsProxyWidget. http://doc.trolltech.com/qtjambi-4.5.2_01/com/trolltech/qt/gui/QGraphicsItemInterface.html Why not use directly methods specified in that interface? Someone else needs to tell me about what those casts are before I can look into them... On keskiviikko 27 lokakuu 2010 14:03:06 Helge Fredriksen wrote: > Forgot the list... > > ---------- Forwarded message ---------- > From: Helge Fredriksen <helgeingv...@gmail.com> > Date: Wed, Oct 27, 2010 at 2:02 PM > Subject: Re: [Qt-jambi-interest] Qt-jambi-interest Digest, Vol 33, Issue 21 > To: Zhongmiao Li <mars.le...@gmail.com> > > > Hello! > > Never really used QGraphicsProxyWidget myself, but I know there were some > changes in how to approach the embedding of widgets as items in a > QGraphcisScene from 4.5 to 4.6. What version are you using? > > Also, I see from the documentation that the usual way to add such widgets > are using the addWidget() method > > http://doc.trolltech.com/qtjambi-4.5.2_01/com/trolltech/qt/gui/QGraphicsProxyWidget.html > ? > > Regards, > Helge Fredriksen > > On Wed, Oct 27, 2010 at 11:51 AM, Zhongmiao Li <mars.le...@gmail.com> wrote: > > > Hello! > > > > I stuck in a strange error. Hope you could help me to solve it, thanks in > > advance! > > > > I use QGraphicsScene.addItem() to add a QGraphicsProxyWidget as an Item, > > and it succeeded. > > > > However, when I use itemAt(pos) to get the item, since the returned item > > is of type QGraphicsItemInterface, so in order to use it > > as QGraphicsProxyWidget , I did a cast from QGraphicsItemInterface to > > QGraphicsProxyWidget, > > but then there was a ClassCastException thrown. > > > > So how can I get this item as type of QGraphicsProxyWidget? Thank you!! > > > > _______________________________________________ > > Qt-jambi-interest mailing list > > Qt-jambi-interest@trolltech.com > > http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest > > > > _______________________________________________ Qt-jambi-interest mailing list Qt-jambi-interest@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest