#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QPushButton* button = new QPushButton("按钮", this);
button->setText("按钮");
button->setFixedSize(200, 200);
button->setStyleSheet("QPushButton {"
"background-color: red;"
"border-radius: 100px;"
"}"
"QPushButton:hover {"
"background-color: green;"
"}"
"QPushButton:pressed {"
"background-color: blue;"
"}"
"QPushButton:!hover:!pressed {"
"background-color: red;"
"}");
QFont* font = new QFont("Arial", 20, QFont::Bold);
button->setFont(*font);
// 设置控件位置
button->move(100, 50);
}
Widget::~Widget()
{
delete ui;
}
Qt 使用setStyleSheet
最新推荐文章于 2024-07-25 16:38:18 发布