QT中让按钮上显示图片,就是让按钮更好看点,有没有简单点可靠的的方法

2024-11-29 19:30:54
推荐回答(1个)
回答(1):

QWidget* widget=new QWidget;
widget->resize(800,800);
widget->show();
QPushButton* pushButton=new QPushButton(widget);
pushButton->setGeometry(10,10,200,200);

QPixmap pixmap;
pixmap.load("mypicture");

pushButton->setFixedSize(pixmap.width(),pixmap.height());
pushButton->setIcon(pixmap);
pushButton->setIconSize(QSize(pixmap.width(),pixmap.height()));
pushButton->setToolTip("Login");
pushButton->show();
还有什么不懂的