@jpn
Thanks, ur solution is working fine...also the movement of items is smooth
I was also pretty much using the same code...
{
Q_OBJECT
public:
~CMainWindow();
private:
//void setupMatrix();
void populateScene();
CViewFrame *viewFrame; // CViewFrame derived from QFrame
//QGraphicsScene *scene;
CScene *scene;
QList<CMacro*> macroList;
protected:
};
CMainWindow
::CMainWindow(QWidget *parent
){
setMouseTracking(true);
populateScene();
viewFrame = new CViewFrame("demo",this);
viewFrame->getView()->setScene(scene);
viewFrame->getView()->setMouseTracking(true);
viewFrame->getView()->setSceneRect(-100,-100,1700,2500);
//setContentsMargins(200,200,600,600);
//scene->setBackgroundBrush(Qt::blue);
setCentralWidget(viewFrame);
viewFrame->getView()->installEventFilter(this);
//viewFrame->getView()->installEventFilter(this);
....
...
...
class CMainWindow : public QMainWindow
{
Q_OBJECT
public:
CMainWindow(QWidget *parent=0);
~CMainWindow();
private:
//void setupMatrix();
void populateScene();
CViewFrame *viewFrame; // CViewFrame derived from QFrame
//QGraphicsScene *scene;
CScene *scene;
QList<CMacro*> macroList;
protected:
bool eventFilter(QObject *obj, QEvent *event);
void mouseMoveEvent ( QMouseEvent * event );
void paintEvent(QPaintEvent *event);
};
CMainWindow::CMainWindow(QWidget *parent)
: QMainWindow(parent)
{
setMouseTracking(true);
populateScene();
viewFrame = new CViewFrame("demo",this);
viewFrame->getView()->setScene(scene);
viewFrame->getView()->setMouseTracking(true);
viewFrame->getView()->setSceneRect(-100,-100,1700,2500);
//setContentsMargins(200,200,600,600);
//scene->setBackgroundBrush(Qt::blue);
setCentralWidget(viewFrame);
viewFrame->getView()->installEventFilter(this);
//viewFrame->getView()->installEventFilter(this);
....
...
...
To copy to clipboard, switch view to plain text mode
The only mistake was i was installing filter on view... rather than viewport
The events are now captured in QEvent::MouseMove of the filter...
So what does actually viewport act like ? why doesnt installing filter on view capture the events ??
@wysota
Ur solution too is working and short & elegant
Can u tell me more on event delegation ?? I saw thru the call stack and came to conclude that...that Qt uses QApplicationPrivate::notify_helper() to properly distrubute the events, and hence its View in the window that receives the events first.
but what will ignore do and how will the events propogate further ?? can u throw more light ?
Thanks a lot both of u guys...just wondering what took u so long to answer
neways it helped me in exploring & learning myself.
Thx again
Bookmarks