I created a simple Qt quick application and I have an issue drawing with QQuickPaintedItem. I checked in debug mode if the paint gets called, but doesn't. Anyway here's my code:
Source:
ParticleHandler::ParticleHandler(QQuickPaintedItem *parent) : QQuickPaintedItem(parent)
{
setFlag(QQuickItem::ItemHasContents);
particle = new Particle();
}
void ParticleHandler::paint(QPainter *painter)
{
QPen pen = QPen(m_color);
painter->setPen(pen);
painter->setRenderHints(QPainter::Antialiasing, true);
painter->drawEllipse(particle->Position.x,particle->Position.y,particle->Radius/2,particle->Radius/2);
}
Header:
ParticleHandler(QQuickPaintedItem *parent = 0);
void paint(QPainter *painter);
Try setting the width and height of your custom item.
import QtQuick 2.0
import Fizika 1.0
Rectangle
{
width: 360
height: 360
Particle
{
width: 100
height: 100
radius: 20
x: 100
y: 200
color: "red"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With