【问题标题】:QtPainter Error Paint device returned engine ==0, type 3 ,Painter not activeQtPainter Error Paint device returned engine ==0, type 3 , Painter not active
【发布时间】:2013-04-24 12:32:14
【问题描述】:

我正在尝试绘制图像的某些点,但我不知道为什么它不起作用。我已经定义了一个 QImage,我想修改一些点。

QImage *cou= new QImage(height,largeur,QImage::Format_Mono);
    cou->fill(1);
    QPainter *fig=new QPainter (cou);
    for (i=0;i<size_;i++)
    {
        fig-> drawPoint(floor(propa[i]),nbmax[i]);
    }

当我执行得到的代码时

QPainter::begin: Paint device returned engine == 0, type: 3

并在以下几行中:

QPainter::drawPoints: Painter not active

【问题讨论】:

标签: c++ qt qpainter


【解决方案1】:
QPainter::begin: Paint device returned engine == 0, type: 3

该错误表示您尝试绘制的图像是空图像。在cou 上使用isNull 进行检查。
图片为null的原因可能是图片构建时heightlargeur参数错误,或者内存不足

【讨论】:

    【解决方案2】:
    QPaintEngine* eng = cou->painterEngine();
    if(eng) {
    //   create QPainter ...
    }
    

    【讨论】:

    • 也许对您的回答进行一些解释会对 OP 和该页面的未来访问者有所帮助?
    猜你喜欢
    • 2021-12-17
    • 2022-11-20
    • 2019-05-07
    • 1970-01-01
    • 2020-06-01
    • 2022-12-02
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    相关资源
    最近更新 更多