1 Create engineering Scale, base class for Qwidget, use layout layout, engineering files for main.cpp widget.h widget.cpp
A Add 2 button controls ZoomIn and Zoomout.
b Add Control Qgraphicsview.
C Signal for clicked
2 widget.h.
#include <QtCore>
#include <QtGui>
#include <QGraphicsItem>
#include <QGraphicsView>
#include <QWidget>
Private
Qreal num;
QString filename;
Qpixmap Pixmap;
Qgraphicsitem *item;
Qgraphicsscene *scene;
Class in the constructor of the 3 widget.cpp.
num=0; Size scale
Scene = new Qgraphicsscene (this);
Ui->graphicsview->setscene (Scene);
Pixmap.load (filename);
Filename= "1.jpg";
Item=scene->addpixmap (PIXMAP);
Item->setflag (qgraphicsitem::itemismovable);
Item->setscale (0.1); Default Load Scale
In the CAO function of the 4 widget.cpp
void Widget::on_zoomin_clicked ()
{
num=num+0.1;
Item->setscale (num);
Qdebug ("num +:%d", num);
}
void Widget::on_zoomout_clicked ()
{
num=num-0.1;
Item->setscale (num-0.1);
Qdebug ("Num 1:%d", num);
}
Click on the button will be the picture larger or smaller, pay attention to num value, not less than 0;
To be Continued ...