我创建了一个简单的 Qt 快速应用程序,但我在使用 QQuickPaintedItem 绘图时遇到了问题。如果调用油漆,我在调试模式下检查,但没有。无论如何,这是我的代码:
来源:
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);
}
标题:
ParticleHandler(QQuickPaintedItem *parent = 0);
void paint(QPainter *painter);