both events work properly on bare mainWindow but when I press inside the graphicsView ,placed inside the mainWindow, only mousePressEvent is responding.
could anybody clarify this issue?
UPD: Here is the code
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "mydialog.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
pix = new QPixmap("/Users/mac/Pictures/wallpaper/Rocks.jpg");
scene->addPixmap(*pix);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::mousePressEvent(QMouseEvent *e)
{
sel_reg_beg_x = e->x();
sel_reg_beg_y = e->y();
qDebug() << "inside press";
}
void MainWindow::mouseMoveEvent(QMouseEvent *e)
{
qDebug() << "inside move";
sel_reg_end_x = e->x();
sel_reg_end_y = e->y();
this->update();
}
setMouseTracking(true)
. – hank