当我在QGraphicsItem
s 中输入文本时,我的程序会产生运行时警告。这些项目是这样创建的:
QGraphicsTextItem* item = new QGraphicsTextItem(this)
item ->setTextInteractionFlags(Qt::TextEditorInteraction);
item ->setCacheMode(ItemCoordinateCache);
我一开始输入,就会显示以下警告:
QPainter::begin: Paint device returned engine 0, type: 2
这也会导致更多类似以下的警告,都表明画家未激活:
QPainter::translate: Painter not active
QPainter::setClipRegion: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setWorldTransform: Painter not active
QPainter::end: Painter not active, aborted
但是,如果我将缓存模式设置为NoCache
,一切都很好。
我该如何解决?