QPushButton *custButton(QString str,QString str1)
{
QPushButton *pushButton= new QPushButton;
pushButton->setGeometry(10,10,200,200); //按钮的位置及大小
pushButton->clearMask();
pushButton->setBackgroundRole( QPalette::Base);
QPixmap mypixmap; mypixmap.load(str);
pushButton->setFixedSize( mypixmap.width(), mypixmap.height() );
pushButton->setMask(mypixmap.createHeuristicMask());
pushButton->setIcon(mypixmap);
pushButton->setIconSize(QSize(mypixmap.width(),mypixmap.height()));
pushButton->setToolTip(str1);
return pushButton;
}
调用代码:
QPushButton *btn=custButton("../login.png", "LOGIN");
为什么这个每次都创建不成功