Hi,
I have used the Canvas Example and it is giving the following error when i run it:
[HTML]release\imagezoomer.o(.text+0xe6e):imagezoomer.cpp : undefined reference to `ImageItem::hit(QPoint const&) const[/HTML]
the function which calls the hit function is :
void ImageZoomer
::contentsMousePressEvent(QMouseEvent* e
) {
const QPoint p
= inverseWorldMatrix
().
map(e
->pos
());
Q3CanvasItemList l=canvas->collisions(p);
for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
if ( (*it)->rtti() == ImageItem::imageRTTI ) {
ImageItem *item = (ImageItem*)(*it);
if ( !(item->hit(p)) )
continue;
}
moving = *it;
moving_start = p;
return;
}
moving = 0;
}
void ImageZoomer::contentsMousePressEvent(QMouseEvent* e)
{
const QPoint p = inverseWorldMatrix().map(e->pos());
Q3CanvasItemList l=canvas->collisions(p);
for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
if ( (*it)->rtti() == ImageItem::imageRTTI ) {
ImageItem *item = (ImageItem*)(*it);
if ( !(item->hit(p)) )
continue;
}
moving = *it;
moving_start = p;
return;
}
moving = 0;
}
To copy to clipboard, switch view to plain text mode
and the hit function is :
ImageItem.h
class ImageItem : public Q3CanvasRectangle
{
public:
//ImageItem();
ImageItem
( QImage img, Q3Canvas
*canvas
);
int rtti () const { return imageRTTI; }
bool hit( const QPoint&) const;
static const int imageRTTI = 984376;
protected:
private:
};
class ImageItem : public Q3CanvasRectangle
{
public:
//ImageItem();
ImageItem( QImage img, Q3Canvas *canvas );
int rtti () const { return imageRTTI; }
bool hit( const QPoint&) const;
static const int imageRTTI = 984376;
protected:
void drawShape( QPainter & );
private:
QImage image;
QPixmap pixmap;
};
To copy to clipboard, switch view to plain text mode
ImageItem.cpp
bool ImageItem
::hit( const QPoint &p
) const {
int ix = p.x()-int(x());
int iy = p.y()-int(y());
if ( !image.valid( ix , iy ) )
return FALSE;
QRgb pixel = image.pixel( ix, iy );
return qAlpha( pixel ) != 0;
}
bool ImageItem::hit( const QPoint &p ) const
{
int ix = p.x()-int(x());
int iy = p.y()-int(y());
if ( !image.valid( ix , iy ) )
return FALSE;
QRgb pixel = image.pixel( ix, iy );
return qAlpha( pixel ) != 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks