How can I change the QGraphicView Item size using mouse.this code generate the 2 rectangles,how can I change the sizes of those rectangles using mouse.
This image shows my expected result.

Capture_193.gif


Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9.  
  10. scene = new QGraphicsScene();
  11. ui->graphicsView->setScene(scene);
  12. scene->setSceneRect(0,0,400,400);
  13.  
  14. // Create the first red rectangle on the graphic scene
  15. rect1->setRect(10,50,100,50);
  16. rect1->setBrush(QBrush(Qt::red));
  17. rect1->setPen(QPen(QBrush(Qt::black),2));
  18. scene->addItem(rect1);
  19.  
  20. // And create a second blue rectangle on the graphic scene
  21. rect2->setRect(150,100,115,75);
  22. rect2->setBrush(QBrush(Qt::blue));
  23. rect2->setPen(QPen(QBrush(Qt::black),2));
  24. scene->addItem(rect2);
  25. }
To copy to clipboard, switch view to plain text mode