qt中如何将png设置为背景(怎么将图片平铺)

只要告诉我怎么平铺就可以了
2025-04-04 16:10:07
推荐回答(2个)
回答1:

MyWidget*w=new MyWidget;
QPalette palette;
palette.setBrush(w->backgroundRole(), QBrush(QPixmap("./pi/backGround.PNG")));
w->setPalette(palette);
w->show();
按上面的做就可以设置背景了,注意替换你自己的widget的类和图片的路径

回答2:

用Painter.setBackGround(your image);
Painter.fillRect(yourRect, your image);
好像是这样的,有点忘了