方案一:使用paintEvent
C/C++ code
void Widget::paintEvent(QPaintEvent*e)
{ QPainter painter(this);
painter.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/xxx.png"));
}
方案二:使用setStyleSheet
C/C++ code
widget->setStyleSheet("border-image: url(:/xxx.png)");