Hello, All !
I developed class,
class XGisCanvasView : public QtCanvasView
{
private:
Q_OBJECT
public:
XGisCanvasView
(QWidget *parent
=NULL);
virtual ~XGisCanvasView (void);
QPoint getPos
(void) const { return scr;
}
signals:
protected:
virtual void contentsMouseReleaseEvent
(QMouseEvent *e
);
virtual void contentsMouseDoubleClickEvent
(QMouseEvent *e
);
private:
QtCanvas* pCanvas;
};
class XGisCanvasView : public QtCanvasView
{
private:
Q_OBJECT
public:
XGisCanvasView (QWidget *parent=NULL);
virtual ~XGisCanvasView (void);
QPoint getPos (void) const { return scr; }
signals:
void contentsMouseMove (QMouseEvent *e);
void mousePress (QMouseEvent *e);
void mouseRelease (QMouseEvent *e);
void mouseDoubleClick (QMouseEvent *e);
void mouseContextMenu (QContextMenuEvent *e);
void resize (QResizeEvent *e);
protected:
virtual void contentsMouseMoveEvent (QMouseEvent *e);
virtual void contentsMousePressEvent (QMouseEvent *e);
virtual void contentsMouseReleaseEvent (QMouseEvent *e);
virtual void contentsMouseDoubleClickEvent (QMouseEvent *e);
virtual void contentsContextMenuEvent (QContextMenuEvent *e);
virtual void resizeEvent (QResizeEvent *e);
private:
QPoint scr;
QtCanvas* pCanvas;
};
To copy to clipboard, switch view to plain text mode
wsview.cpp
XGisCanvasView
:: XGisCanvasView(QWidget *parent
/*=NULL*/) : QtCanvasView
(parent
), scr
(QPoint(0,
0)){
setMouseTracking ( true );
viewport()->setMouseTracking ( true );
int x = width();
int y = height();
if ( parent )
{
x = parent->width();
y = parent->height();
}
qDebug ("width = %d height = %d", x, y);
pCanvas = new QtCanvas ( );
qDebug ("QtCanvas init");
pCanvas->resize (x, y);
setCanvas( pCanvas );
qDebug ("QtCanvas set");
this->canvas()->update();
bool isTrace = hasMouseTracking();
bool isVTrace = viewport()->hasMouseTracking();
if ( isTrace )
qDebug ("Mouse tracking is on");
else
qDebug ("Mouse tracking is off");
if ( isVTrace )
qDebug ("Viewport Mouse tracking is on");
else
qDebug ("Viewport Mouse tracking is off");
}
XGisCanvasView :: XGisCanvasView(QWidget *parent/*=NULL*/) : QtCanvasView (parent), scr (QPoint(0, 0))
{
setMouseTracking ( true );
viewport()->setMouseTracking ( true );
int x = width();
int y = height();
if ( parent )
{
x = parent->width();
y = parent->height();
}
qDebug ("width = %d height = %d", x, y);
pCanvas = new QtCanvas ( );
qDebug ("QtCanvas init");
pCanvas->resize (x, y);
setCanvas( pCanvas );
qDebug ("QtCanvas set");
this->canvas()->update();
bool isTrace = hasMouseTracking();
bool isVTrace = viewport()->hasMouseTracking();
if ( isTrace )
qDebug ("Mouse tracking is on");
else
qDebug ("Mouse tracking is off");
if ( isVTrace )
qDebug ("Viewport Mouse tracking is on");
else
qDebug ("Viewport Mouse tracking is off");
}
To copy to clipboard, switch view to plain text mode
After setCanvas() function variables isTrace and isVTrace are true, but event contentsMouseMoveEvent (QMouseEvent *e) does not generated.
If I comment setCanvas() function, all mouse movements are traced normally. Where is problem ?
Best regards,
Yuriy Rusinov.
Bookmarks