[Qt-interest] Overridden wheelEvent not being called

Cole, Derek dcole at integrity-apps.com
Fri Jan 21 20:53:50 CET 2011


Wow, turns out that was it. Thanks for the help in the right direction. I have to admit I am a little bit of a C++ newb, and had just copied most of that code snippet from some other thing I  found online

Thanks again
Derek

-----Original Message-----
From: qt-interest-bounces+dcole=integrity-apps.com at qt.nokia.com on behalf of Andreas Pakulat
Sent: Fri 1/21/2011 2:23 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Overridden wheelEvent not being called
 
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.
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110121/5d833152/attachment.html 


More information about the Qt-interest-old mailing list