2 #include "qmapview.moc" 6 #include <QGraphicsScene> 13 setViewport(
new QGLWidget(QGLFormat(QGL::SampleBuffers)));
15 setCacheMode(CacheBackground);
16 setRenderHint(QPainter::Antialiasing);
17 setTransformationAnchor(AnchorUnderMouse);
18 setResizeAnchor(AnchorViewCenter);
21 setMinimumSize(400, 400);
22 setWindowTitle(
tr(
"QMapView"));
27 switch (event->key()) {
44 QGraphicsView::keyPressEvent(event);
51 scaleView(pow((
double)2, -event->delta() / 240.0));
57 qreal factor = matrix().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
58 if (factor < 0.07 || factor > 100)
61 scale(scaleFactor, scaleFactor);
void wheelEvent(QWheelEvent *event)
void keyPressEvent(QKeyEvent *event)
void scaleView(qreal scaleFactor)