![](/img/trans.png)
[英]I'm trying to call void functions in another function, but I don't know how to properly place them
[英]how are these functions called if I didn't call them?
我是 QT 的新手。 如果我没有调用这些函数,它们是如何自动调用的?
也许在父类的某个地方有连接以某种方式连接它们并启动它们?
我知道这里会有一个默认构造函数,但是如果默认构造函数为空,这些函数是怎么调用的
class CustomItem : public QGraphicsItem{
上市:
QRectF boundingRect() const override{
return QRectF(0, 0, 80, 80);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->fillRect(boundingRect(),Qt::red);
}
}物品;
任何拥有类对象的指针或引用的人都可以调用公共方法。
大概这种类型的对象被添加到QGraphicsScene
,其中包括调用boundingRect
以确定您的CustomItem
占用多少空间,并在需要使用该项目paint
场景的一部分时进行绘制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.