#include #include #include #include #include #include class fancyButton : public QPushButton { public: QIcon defaultIcon; fancyButton(int Width, int Height, QIcon defaultIn,QString tips="") { defaultIcon = defaultIn; this->setToolTip(tips); this->setIcon(defaultIcon); // ÉèÖÃͼ±ê this->setFixedHeight(Height); this->setFixedWidth(Width); toDefault(); } void toDefault() { this->setStyleSheet(QString("QPushButton { background-color: transparent;" "border: 0px solid red;" "border-radius: 0px;" "}" "QPushButton:focus {" " outline: none;" "}" "QPushButton:hover { background-color: rgb(%1); }").arg(sColor_GoldWithBlack)); } }; class fancyButtonText : public QPushButton { public: QString text; fancyButtonText(int Width, int Height, QString textIn, QString tips = "") { QPalette palette; palette.setColor(QPalette::WindowText, Qt::white); QFont font("΢ÈíÑźÚ", 14, QFont::Bold); text = textIn; this->setToolTip(tips); this->setText(text); if (Height != -1) this->setFixedHeight(Height); else this->setMaximumHeight(9999); if (Width != -1) this->setFixedWidth(Width); else this->setMaximumHeight(9999); this->setPalette(palette); this->setFont(font); toDefault(); } void toDefault() { this->setStyleSheet(QString("QPushButton { background-color: transparent;" "color: white;" "border: 0px solid red;" "border-radius: 0px;" "}" "QPushButton:focus {" " outline: none;" "}" "QPushButton:hover { background-color: rgb(%1); }").arg(sColor_GoldWithBlack)); } void toRed() { this->setStyleSheet(QString("QPushButton { background-color: rgb(%1);" "color: white;" "border: 0px solid red;" "border-radius: 0px;" "}" "QPushButton:focus {" " outline: none;" "}" "QPushButton:hover { background-color: rgb(%2); }").arg(sColor_Red).arg(sColor_RedWithWhite)); } void toGreen() { this->setStyleSheet(QString("QPushButton { background-color: %1;" "color: white;" "border: 0px solid red;" "border-radius: 0px;" "}" "QPushButton:focus {" " outline: none;" "}" "QPushButton:hover { background-color: rgb(%2); }").arg(sColor_Red).arg(sColor_RedWithWhite)); } }; class gradientButton : public QPushButton { public: QString text; gradientButton(int Width, int Height, QString textIn, QString tips = "") { QPalette palette; palette.setColor(QPalette::WindowText, Qt::white); QFont font("΢ÈíÑźÚ", 14, QFont::Bold); text = textIn; this->setToolTip(tips); this->setText(text); this->setFixedHeight(Height); this->setFixedWidth(Width); this->setPalette(palette); this->setFont(font); toDefault(); } void toDefault() { this->setStyleSheet( QString("QPushButton {" " color: white;" " background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, " " stop:1 rgba(%1, 255), " " stop:0.9 rgba(%1, 255)," " stop:0.9 rgba(255, 255, 255, 0)" " ); " " border: none;" " padding: 10px;" "}" "QPushButton:hover {" " color: white;" " background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, " " stop:1 rgba(%1, 255), " " stop:0.9 rgba(%1, 255)," " stop:0.9 rgba(255, 255, 255, 0.2)," " stop:0.5 rgba(255, 255, 255, 0) " " ); " " border: none;" " padding: 10px;" "}" "QPushButton:focus {" " outline: none;" "}" ).arg(sColor_Gold)); } void pressed() { this->setStyleSheet( QString("QPushButton {" " color: white;" " background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, " " stop:1 rgba(%1, 255), " " stop:0.9 rgba(%1, 255)," " stop:0.9 rgba(255, 255, 255, 0.3)," " stop:0.3 rgba(255, 255, 255, 0) " " ); " " border: none;" " padding: 10px;" "}" "QPushButton:focus {" " outline: none;" "}" ).arg(sColor_Gold)); } }; #pragma once