1.概要
2.代码
#include "dialog.h"
#include "ui_dialog.h"
#include <QPushButton>
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog)
{
ui->setupUi(this);
QPushButton *button = new QPushButton("My Button", this);
button->setGeometry(QRect(10, 10, 80, 30)); // 设置位置和大小
button->setStyleSheet("QPushButton { background-color: red; }"); // 设置样式表
}
Dialog::~Dialog()
{
delete ui;
}
3.运行结果
