Qt添加资源文件无法显示资源文件问题

在添加资源文件以后需要再qmake一遍,再run才行。。。亲身经历!!!

void Widget::paintEvent(QPaintEvent *)
{
     

    gridw = width()/10;
    gridh = height()/10;
    startx = gridw;
    starty = gridh;

    QPainter p(this);
    p.drawPixmap(rect(),QPixmap(":/new/prefix1/image/dishi.png"));
    //p.drawPixmap(rect(),QPixmap("../image/dishi.png"));

    QPen pen;
    pen.setWidth(4);
    pen.setColor(Qt::red);
    p.setPen(pen);
    for(int i=0;i<=8;++i)
    {
     
        p.drawLine(startx,starty+i*gridw,startx+8*gridh,starty+i*gridw);
        p.drawLine(startx+i*gridh,starty,startx+i*gridw,starty+8*gridh);
    }
    if(cx!=-1 &&cy!=-1)
    p.drawPixmap(startx+cx*gridh,starty+cy*gridw,gridh,gridw,QPixmap(":/new/prefix1/image/face.png"));

}

你可能感兴趣的:(Qt,C++,C++客户端开发,Qt资源文件)