Qt Quick based coffee brewing control chart.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

qmllineitem.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef QMLLINEITEM_H
  2. #define QMLLINEITEM_H
  3. #include <QDeclarativeItem>
  4. #include <QPainter>
  5. class QmlLineItem : public QDeclarativeItem
  6. {
  7. Q_OBJECT
  8. Q_PROPERTY(int x1 READ x1 WRITE setX1 NOTIFY x1Changed);
  9. Q_PROPERTY(int y1 READ y1 WRITE setY1 NOTIFY y1Changed);
  10. Q_PROPERTY(int x2 READ x2 WRITE setX2 NOTIFY x2Changed);
  11. Q_PROPERTY(int y2 READ y2 WRITE setY2 NOTIFY y2Changed);
  12. Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged);
  13. Q_PROPERTY(int penWidth READ penWidth WRITE setPenWidth NOTIFY penWidthChanged);
  14. public:
  15. QmlLineItem(QDeclarativeItem *parent = NULL);
  16. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
  17. QWidget *widget);
  18. int x1() const;
  19. int y1() const;
  20. int x2() const;
  21. int y2() const;
  22. QColor color() const;
  23. int penWidth() const;
  24. void setX1(int x1);
  25. void setY1(int y1);
  26. void setX2(int x2);
  27. void setY2(int y2);
  28. void setColor(const QColor &color);
  29. void setPenWidth(int newWidth);
  30. signals:
  31. void x1Changed();
  32. void y1Changed();
  33. void x2Changed();
  34. void y2Changed();
  35. void colorChanged();
  36. void penWidthChanged();
  37. private:
  38. void updateSize();
  39. int m_x1;
  40. int m_y1;
  41. int m_x2;
  42. int m_y2;
  43. QColor m_color;
  44. int m_penWidth;
  45. };
  46. QML_DECLARE_TYPE(QmlLineItem)
  47. #endif