chore:更新取消按钮样式

This commit is contained in:
2025-06-15 16:47:23 +08:00
parent e539fb5912
commit 525a90f441

View File

@@ -93,15 +93,17 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
progressBarOption.text = QString("%1%").arg(progress); progressBarOption.text = QString("%1%").arg(progress);
progressBarOption.textVisible = true; progressBarOption.textVisible = true;
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
QStyleOptionButton cancelOption;
cancelOption.rect = QRect(progressRect.right() + 10, rect.top() + (rect.height() - 30) / 2, 70, 30); // 修改后的取消按钮绘制代码
cancelOption.text = "取消"; QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30);
cancelOption.palette.setColor(QPalette::Button, QColor("#ff4444")); painter->setPen(Qt::NoPen);
cancelOption.palette.setColor(QPalette::ButtonText, Qt::white); painter->setBrush(QColor("#ff4444")); // 红色背景
cancelOption.state = QStyle::State_Enabled; painter->drawRoundedRect(buttonRect, 4, 4); // 圆角矩形
QApplication::style()->drawControl(QStyle::CE_PushButton, &cancelOption, painter);
painter->setPen(Qt::white); // 白色文字
painter->setFont(option.font);
painter->drawText(buttonRect, Qt::AlignCenter, "取消");
} else { } else {
// 修改后的更新按钮绘制代码
QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30);
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
painter->setBrush(QColor("#e9effd")); // 背景色 painter->setBrush(QColor("#e9effd")); // 背景色