Created
July 21, 2015 12:18
-
-
Save VictorKoenders/5c340f776b8c4f8fc192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "greenhouserenderer.h" | |
#include <QDebug> | |
GreenhouseRenderer::GreenhouseRenderer(QQuickItem *parent) | |
: QQuickPaintedItem(parent) | |
{ | |
setAcceptedMouseButtons(Qt::LeftButton); | |
} | |
void GreenhouseRenderer::paint(QPainter *painter) | |
{ | |
QBrush brush(QColor("#007430")); | |
painter->setBrush(brush); | |
painter->setPen(Qt::NoPen); | |
painter->setRenderHint(QPainter::Antialiasing); | |
painter->drawRect(10, 10, boundingRect().width() - 20, boundingRect().height() - 20); | |
} | |
void GreenhouseRenderer::mousePressEvent(QMouseEvent* event){ | |
qDebug() << "mousePressEvent " << event->x() << "x" << event->y(); | |
} | |
void GreenhouseRenderer::mouseMoveEvent(QMouseEvent* event){ | |
qDebug() << "mouseMoveEvent " << event->x() << "x" << event->y(); | |
} | |
void GreenhouseRenderer::mouseReleaseEvent(QMouseEvent *event){ | |
qDebug() << "mouseReleaseEvent " << event->x() << "x" << event->y(); | |
} | |
void GreenhouseRenderer::touchEvent(QTouchEvent *event){ | |
qDebug() << "touchEvent " << event->touchPoints()[0].pos().x() << "x" << event->touchPoints()[0].pos().y(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef GREENHOUSERENDERER_H | |
#define GREENHOUSERENDERER_H | |
#include <QtQuick> | |
#include <QMouseEvent> | |
class GreenhouseRenderer : public QQuickPaintedItem | |
{ | |
Q_OBJECT | |
public: | |
GreenhouseRenderer(QQuickItem *parent = 0); | |
void paint(QPainter *painter); | |
void mousePressEvent(QMouseEvent *event); | |
void mouseMoveEvent(QMouseEvent *event); | |
void mouseReleaseEvent(QMouseEvent *event); | |
void touchEvent(QTouchEvent *event); | |
}; | |
#endif // GREENHOUSERENDERER_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment