summaryrefslogtreecommitdiffstats
path: root/demos/chip/view.h
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2010-11-15 13:42:49 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2010-11-15 13:47:21 (GMT)
commit0f905e860804dbb4182663f1628a359e3c0795b1 (patch)
treee24f22eaa8d7c8abd77ddfbefc6faf3144f3cd9f /demos/chip/view.h
parente084fbbe18d771702312d7db65030aaaf18b596b (diff)
downloadQt-0f905e860804dbb4182663f1628a359e3c0795b1.zip
Qt-0f905e860804dbb4182663f1628a359e3c0795b1.tar.gz
Qt-0f905e860804dbb4182663f1628a359e3c0795b1.tar.bz2
Chip demo: makes scene interaction easier.
It is now possible to zoom in or out using the mouse wheel (while pressing the CTRL key). It is also possible to switch between two pointer modes: select and drag. The first one allows to select items and move them, the second allows to drag the scene. Reviewed-by: bnilsen
Diffstat (limited to 'demos/chip/view.h')
-rw-r--r--demos/chip/view.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/demos/chip/view.h b/demos/chip/view.h
index 8047b8b..67c7675 100644
--- a/demos/chip/view.h
+++ b/demos/chip/view.h
@@ -43,12 +43,27 @@
#define VIEW_H
#include <QFrame>
+#include <QGraphicsView>
-QT_FORWARD_DECLARE_CLASS(QGraphicsView)
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSlider)
QT_FORWARD_DECLARE_CLASS(QToolButton)
+class View;
+
+class GraphicsView : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ GraphicsView(View *v) : QGraphicsView(), view(v) { }
+
+protected:
+ void wheelEvent(QWheelEvent *);
+
+private:
+ View *view;
+};
+
class View : public QFrame
{
Q_OBJECT
@@ -57,22 +72,27 @@ public:
QGraphicsView *view() const;
+public slots:
+ void zoomIn(int level = 1);
+ void zoomOut(int level = 1);
+
private slots:
void resetView();
void setResetButtonEnabled();
void setupMatrix();
+ void togglePointerMode();
void toggleOpenGL();
void toggleAntialiasing();
void print();
-
- void zoomIn();
- void zoomOut();
void rotateLeft();
void rotateRight();
-
+
private:
- QGraphicsView *graphicsView;
+ GraphicsView *graphicsView;
QLabel *label;
+ QLabel *label2;
+ QToolButton *selectModeButton;
+ QToolButton *dragModeButton;
QToolButton *openGlButton;
QToolButton *antialiasButton;
QToolButton *printButton;