qt 简单实验 用代码添加控件

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.运行结果

相关推荐
外收内放5 分钟前
FastAPI猜字谜实战(5):会话管理
开发语言·python·学习·fastapi
Ai-_Man6 分钟前
Microsoft Copilot对话数据怎么导入到另外一个Microsoft Copilot账号里去?AI导出鸭
开发语言·javascript·人工智能·microsoft·chatgpt·ecmascript·copilot
H.莓飛11 分钟前
【数据结构】归并与外排序
linux·服务器·c语言·开发语言·数据结构·visual studio
技术老孙13 分钟前
给 Agent 装上对话框 —— AgentScope-Java 接入 Spring Boot 与 SSE 流式实战
java·开发语言·spring boot
星夜离尘568 小时前
MATLAB 工程实验:不等间隔流量积分,先把缺口与覆盖率说清楚
开发语言·matlab·时间戳·数据质量·数值积分
Ai-_Man9 小时前
Meta Muse还是不可以导出左侧所有对话,只能点进去单条内容导出,方法不对吗?
开发语言·人工智能·ai·小程序·c#·1024程序员节
梓豪csd9 小时前
消息订阅中心:谁该收到哪条通知
java·开发语言·人工智能·低代码·自动化·1024程序员节
学逆向的9 小时前
C 枚举变量
c语言·开发语言·网络安全
Sakura_j_h_10 小时前
Python 在定时任务里输出 emoji,UnicodeEncodeError 从哪来
开发语言·字符编码·windows·python·定时任务
小成2023032026515 小时前
C++~07补充
开发语言·c++