Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QPainter:喷漆设备返回引擎0_Qt_Qgraphicstextitem - Fatal编程技术网

Qt QPainter:喷漆设备返回引擎0

Qt QPainter:喷漆设备返回引擎0,qt,qgraphicstextitem,Qt,Qgraphicstextitem,当我在QGraphicsSitems中键入文本时,我的程序会生成运行时警告。项目的创建方式如下所示: QGraphicsTextItem* item = new QGraphicsTextItem(this) item ->setTextInteractionFlags(Qt::TextEditorInteraction); item ->setCacheMode(ItemCoordinateCache); 我一开始键入,就会显示以下警告: QPainter::begin: Pai

当我在QGraphicsSitems中键入文本时,我的程序会生成运行时警告。项目的创建方式如下所示:

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,则一切正常


如何修复此问题?

您能否提供代码所在的上下文?这是主要的第一件事,还是你设置了QGraphicsView和QGraphicscene?我设置了QGraphicsView和QGraphicscene,并在QGraphicscene中添加了一些从QGraphicsObject继承的自定义图形项,所有这些都可以使用缓存和不使用缓存。项是子自定义图形对象请提供一个较小的编译示例。如果直接将项添加到场景中并键入文本项单行全部ok,如果有两行或更多行则出错