37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
#include <QApplication>
|
|||
|
|
#include <QPushButton>
|
||
|
|
#include <QPropertyAnimation>
|
||
|
|
#include <QMouseEvent>
|
||
|
|
#include <globalStruct.h>
|
||
|
|
#include <qpainter.h>
|
||
|
|
class toolBarButton : public QPushButton {
|
||
|
|
public:
|
||
|
|
QIcon defaultIcon;
|
||
|
|
toolBarButton(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;" // 设置边框半径为0,确保没有圆角
|
||
|
|
"}"
|
||
|
|
"QPushButton:hover { background-color: rgb(%1); }").arg(sColor_BlackWithWhite));
|
||
|
|
|
||
|
|
}
|
||
|
|
void pressed()
|
||
|
|
{
|
||
|
|
this->setStyleSheet(QString("QPushButton { background-color:rgb(%1) ;"
|
||
|
|
"border: 0px solid red;" // 显式设置边框
|
||
|
|
"border-radius: 0px;" // 设置边框半径为0,确保没有圆角
|
||
|
|
"}"
|
||
|
|
"QPushButton:hover { background-color: rgb(%2); }").arg(sColor_GoldWithBlack).arg(sColor_Gold)); // 设置透明背景和悬停时的背景色
|
||
|
|
}
|
||
|
|
};
|
||
|
|
#pragma once
|