Mouse Move event not functioning in Qscrollarea in tab widget
Hi,
I Have a QScrollArea on my UI and ImageLabel inside QScrollarea.
I have successfully executed the code to scale the image with resize(pixmap) using Mainwindow::wheelEvent() and move the image within the QscrollArea with move(pixmap) using Mainwindow::mousePressEvent(),Mainwindow::mouseMov eEvent() and Mainwindow::mouseReleaseEvent().
When my UI contains the QScrollArea alone with imageLabel inside it, the program works fine.
But when I put QScrollArea inside a tabwidget, there are multiple issues.
1. Mainwindow::wheelEvent() works perfectly fine.
1. When I press left mouse button inside QScrollArea the controller does not enter into function Mainwindow::mousePressEvent()(Nothing happens) but when I press right mouse button, the controller enters into function Mainwindow::mousePressEvent().
2. The controller does not even enter into Mainwindow::mouseMoveEvent() function when I left/right click and drag the mouse inside QScrollArea.
What should I do on this??
Am I missing anything??
Qt Code:
Code:
{
int numDegree = myEvent->delta() / 8;
double numStep = numDegree / 15.0f ;
numStep = pow(0.9f,numStep);
scaleImage(numStep);
ui
->imageLabel
->setCursor
(QCursor(Qt
::ArrowCursor));
}
{
if (event->button() == Qt::LeftButton)
{
lastDragPos = event->pos();
}
}
{
if (event->buttons() & Qt::LeftButton)
{
lastDragPos = event->pos();
}
ui->imageLabel->move(pixmapOffset);
printf("MoveEvent-Pixmap offset x: %d and y: %d \n",pixmapOffset.x(),pixmapOffset.y());
ui
->imageLabel
->setCursor
(QCursor(Qt
::ClosedHandCursor));
}
{
if (event->button() == Qt::LeftButton)
{
pixmapOffset += event->pos() - lastDragPos;
}
ui
->imageLabel
->setCursor
(QCursor(Qt
::OpenHandCursor));
}
Re: Mouse Move event not functioning in Qscrollarea in tab widget
If you wish to handle an event in object X, you need to do that in implementation of object X, not its parent or grandparent.