CustomMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(strReturn);
msgBox.setStyleSheet("background-color: qlineargradient(x1: 0, y1: 1, x2: 0, y2: 0,stop: 0 rgba(255, 255, 255, 100%),stop: 1 rgba(10, 144, 255, 100%));"); // 设置渐变色
QObjectList objChildList = msgBox.children(); //把文字和按键里的渐变色去掉
for (int i = 0; i < objChildList.size(); i++)
{
QObject *pObj= objChildList.at(i);
if (pObj->inherits("QWidget"))
{
QWidget *pWidget = (QWidget*)pObj;
pWidget->setStyleSheet("background-color: transparent");
}
}
QPushButton *Button1 = msgBox.addButton(tr(" 取消"),QMessageBox::NoRole);
Button1->setFont(QFont("Ubuntu",30));
Button1->setFocusPolicy(Qt::NoFocus);
Button1->setStyleSheet("border-image: url(:/new/prefix1/newImage/Buttom-2.png);");
QPushButton *Button2 = msgBox.addButton(tr(" 确认"),QMessageBox::YesRole);
Button2->setFont(QFont("Ubuntu",30));
Button2->setFocusPolicy(Qt::NoFocus);
Button2->setStyleSheet("border-image: url(:/new/prefix1/newImage/Buttom-2.png);");
msgBox.exec();
if (msgBox.clickedButton() == Button2)
qDebug()<<"click OK\n";