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.

50 lines
1.1 KiB

#include "qquickcustomitem.h"
QQuickCustomItem::QQuickCustomItem(QQuickPaintedItem *parent) :
QQuickPaintedItem(parent),
m_color(Qt::red),
m_needUpdate(true)
{
setFlag(QQuickItem::ItemHasContents);
}
void QQuickCustomItem::paint(QPainter *painter)
{
const int scale = 1;
QPen pen;
pen.setWidth(3);
pen.setDashPattern({ 0.0, 1.0 * scale, 1.0 * scale, 1.0 * scale });
pen.setColor(m_color);
QPainterPath path;
// path.moveTo(width() / 2, 0);
// path.lineTo(width(), height());
// path.lineTo(0, height());
// path.lineTo(width() / 2, 0);
qWarning()<<painter->window().width()<<" "<<painter->window().height();
path.moveTo(QPoint(100, 0));
path.arcTo(QRectF(0, 0, painter->window().width(), painter->window().height()), 90, 270);
painter->setPen(pen);
painter->drawPath(path);
}
QColor QQuickCustomItem::color() const
{
return m_color;
}
void QQuickCustomItem::setColor(const QColor &color)
{
if(m_color != color) {
m_color = color;
m_needUpdate = true;
update();
emit colorChanged();
}
}