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:
Qt Code:
  1. void MainWindow::wheelEvent(QWheelEvent *myEvent)
  2. {
  3. int numDegree = myEvent->delta() / 8;
  4. double numStep = numDegree / 15.0f ;
  5. numStep = pow(0.9f,numStep);
  6. scaleImage(numStep);
  7. ui->imageLabel->setCursor(QCursor(Qt::ArrowCursor));
  8. }
  9.  
  10. void MainWindow::mousePressEvent(QMouseEvent *event)
  11. {
  12. if (event->button() == Qt::LeftButton)
  13. {
  14. lastDragPos = event->pos();
  15. }
  16.  
  17. }
  18.  
  19. void MainWindow::mouseMoveEvent(QMouseEvent *event)
  20. {
  21. if (event->buttons() & Qt::LeftButton)
  22. {
  23. lastDragPos = event->pos();
  24. }
  25.  
  26. ui->imageLabel->move(pixmapOffset);
  27.  
  28.  
  29. printf("MoveEvent-Pixmap offset x: %d and y: %d \n",pixmapOffset.x(),pixmapOffset.y());
  30. ui->imageLabel->setCursor(QCursor(Qt::ClosedHandCursor));
  31. }
  32.  
  33. void MainWindow::mouseReleaseEvent(QMouseEvent *event)
  34. {
  35. if (event->button() == Qt::LeftButton)
  36. {
  37.  
  38. pixmapOffset += event->pos() - lastDragPos;
  39.  
  40. }
  41.  
  42. ui->imageLabel->setCursor(QCursor(Qt::OpenHandCursor));
  43.  
  44. }
To copy to clipboard, switch view to plain text mode