summaryrefslogtreecommitdiffstats
path: root/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-12-10 08:16:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-26 13:31:45 +0100
commit717a0a9d043bb5052930fa990865850e96a99eb5 (patch)
treeb75ff6205a60211d9bbbdae45d8c10ff522e39dc /tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
parentc56f73cc1e8f4a0a2d55d713b152548efcc595aa (diff)
QGraphicsView - emit signal when rubber band changes.
The rubberBandRect function is nice to have, but this patch makes it easier to track the rubber band by emiting a signal on change. That makes it easier (and less clumsy/hacky) to show information related to the rubber band. Change-Id: If65eb85d743a1804be3fdb823a821423411e9745 Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp')
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
index 85881ca67a..f6077e3044 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
@@ -60,11 +60,12 @@ public:
class MyGraphicsView : public QGraphicsView
{
-
+ Q_OBJECT
public:
MyGraphicsView(QWidget *w, QLabel *l) : QGraphicsView(w), rubberbandLabel(l)
{
setDragMode(QGraphicsView::RubberBandDrag);
+ connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF)));
}
protected:
void mouseMoveEvent(QMouseEvent *event)
@@ -80,29 +81,17 @@ protected:
int yglobal = event->globalY();
if (yglobal > bottomPos)
verticalScrollBar()->setValue(verticalScrollBar()->value() + 10);
- updateRubberbandInfo();
}
- void mouseReleaseEvent(QMouseEvent *event)
- {
- QGraphicsView::mouseReleaseEvent(event);
- updateRubberbandInfo();
- }
-
- void wheelEvent (QWheelEvent *event)
- {
- QGraphicsView::wheelEvent(event);
- updateRubberbandInfo();
- }
-
- void updateRubberbandInfo()
+protected slots:
+ void updateRubberbandInfo(QRect r, QPointF from, QPointF to)
{
QString textToShow;
QDebug s(&textToShow);
- s << rubberBandRect();
- if (rubberbandLabel->text() != textToShow)
- rubberbandLabel->setText(textToShow);
+ s << r << from << to;
+ rubberbandLabel->setText(textToShow);
}
+protected:
QLabel *rubberbandLabel;
};
@@ -135,3 +124,5 @@ int main(int argc, char *argv[])
app.exec();
return 0;
}
+
+#include "rubberbandtest.moc"