C++ Qt/C++;QPaint::pen:画师未激活(QPaint::begin:画师设备返回的引擎==0,类型:1)

C++ Qt/C++;QPaint::pen:画师未激活(QPaint::begin:画师设备返回的引擎==0,类型:1),c++,qt,qpainter,C++,Qt,Qpainter,这是我的代码: QPaintDevice *paintDevice = this; QImage image; if (!isEnabled()) { // If the globe covers fully the screen then we can use the faster // RGB32 as there are no translucent areas involved. QImage::Format

这是我的代码:

    QPaintDevice *paintDevice = this;
    QImage image;
    if (!isEnabled())
    {
        // If the globe covers fully the screen then we can use the faster
        // RGB32 as there are no translucent areas involved.
        QImage::Format imageFormat = ( ui->MarbleWidget_plan->viewport()->mapCoversViewport() )
                                     ? QImage::Format_RGB32
                                     : QImage::Format_ARGB32_Premultiplied;
        // Paint to an intermediate image
        image = QImage( rect().size(), imageFormat );
        image.fill( Qt::transparent );
        paintDevice = ℑ
    }

gp = new GeoPainter ( paintDevice, ui->MarbleWidget_plan->viewport(), ui->MarbleWidget_plan->mapQuality() );
    drawMission();
我正在使用大理石小部件:

我正试图在这张地图上画画

这是我的使命():


谢谢你的帮助!为了你的时间

1。你在做奇怪的事情。为什么需要画笔?2您没有显示用于绘制的代码以及创建QPaint的位置!如果你有这样的问题,为什么不做呢!我只是修改了我的问题以便更清楚一些,谢谢:)并且
QPainter::begin
在哪里或者它的构造函数被调用了?QPainter::begin是通过在
paintDevice=&image您获取的对象地址在执行
drawMission
时将不再存在。你不能在毁坏的物体上画画!
void video::drawMission(){

    GeoDataCoordinates France( 2.2, 48.52, 0.0, GeoDataCoordinates::Degree );
    gp->setPen( QColor( 0, 0, 0 ) );
    gp->drawText( France, "France" );

    GeoDataCoordinates Canada( -77.02, 48.52, 0.0, GeoDataCoordinates::Degree );
    gp->setPen( QColor( 0, 0, 0 ) );
    gp->drawText( Canada, "Canada" );

    //A line from France to Canada without tessellation

    GeoDataLineString shapeNoTessellation( NoTessellation );
    shapeNoTessellation << France << Canada;

    gp->setPen( oxygenSkyBlue4 );
    gp->drawPolyline( shapeNoTessellation );

    //The same line, but with tessellation

    GeoDataLineString shapeTessellate( Tessellate );
    shapeTessellate << France << Canada;

    gp->setPen( oxygenBrickRed4 );
    gp->drawPolyline( shapeTessellate );

    //Now following the latitude circles

    GeoDataLineString shapeLatitudeCircle( RespectLatitudeCircle | Tessellate );
    shapeLatitudeCircle << France << Canada;

    gp->setPen( oxygenForestGreen4 );
    gp->drawPolyline( shapeLatitudeCircle );
}
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::pen: Painter not active
QPainter::setPen: Painter not active
QPainter::fontMetrics: Painter not active
QPainter::fontMetrics: Painter not active
QPainter::setPen: Painter not active
QPainter::fontMetrics: Painter not active
QPainter::fontMetrics: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active
QPainter::setPen: Painter not active