我有一个QGraphicsItem元素(从 子类化QGraphicsItem)作为子元素 a QGraphicsTextItem。
问题是该paint(...)方法QGraphicsItem被无限调用。
这是我的QGraphicsItem元素中的paint方法QGraphicsTextItem:
void rectangle_element::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
{
painter->drawRoundedRect( -10, -10, 80, 40, 5, 5 );
painter->drawStaticText( -10, -10, QStaticText( "some text" ) );
text_item->setPlainText( "more text" );
}
我不能setCacheMode与QGraphicsItem::CacheMode::NoCache.
我正在使用 Qt 5.6。
更新:
- 是类的
text_item成员,它在初始化列表中被初始化。