[Qt-interest] Overridden wheelEvent not being called
Andreas Pakulat
apaku at gmx.de
Fri Jan 21 20:23:14 CET 2011
On 21.01.11 12:27:18, Cole, Derek wrote:
> Sorry to keep replying to myself..just some thoughts...
>
> Is it possible that the way I am creating the new item, which is within a function, is getting deleted when the function goes out of scope? I have the scene declared as a global variable, but not the ImagePixmapItem. Does it need to be declared globally before I can use it, even after its been put in the scene?
Thats not your problem, its much much simpler I think. I don't know
graphicsview in-depth, but I wonder why you expect the addPixmap
function of QGraphicsScene to return your custom item? This is a
convenience function to create and add a QGraphicsPixmapItem from a
QPixmap. So of course the QGraphicsPixmapItem::wheelEvent is being
called. You need to create your custom item yourself and then add it via
addItem().
Additionally you should probably read up on static_cast<> vs.
dynamic_cast. If you had done a dynamic_cast it would've return a null
pointer and hence would've been easier to notice that the returned item
is not of your own class.
Andreas
--
Your boss climbed the corporate ladder, wrong by wrong.
More information about the Qt-interest-old
mailing list