技术栈

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

科学的发展-只不过是读大自然写的代码2024-06-22 19:53

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

上一篇:正则表达式
下一篇:Redis 集群 - 数据分片算法
相关推荐
xcyxiner
9 小时前
DicomViewer (后台线程处理文件)4
qt
xcyxiner
16 小时前
DicomViewer (添加模型类)3
qt
xcyxiner
1 天前
DicomViewer (目录调整) 2
qt
xcyxiner
2 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR006
3 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术
3 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript
码云数智-园园
3 天前
C++20 Modules 模块详解
java·开发语言·spring
swordbob
3 天前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
源分享
3 天前
Java线程同步的多种实现方法(非常详细)
java·开发语言·jvm
Luminous.
3 天前
C语言--day30
c语言·开发语言
热门推荐
012026年6月AI行业全景:从百模大战到Agent元年,这30天发生了什么?022026年6月AI大模型全景报告:GPT-5.6、Claude Opus 4.8、Gemini 3.5,中美AI三足鼎立谁主沉浮?032026 年 AI 编程工具终极横评:Cursor vs Claude Code vs Copilot vs Windsurf04【AI】2026 年具身智能模型和世界模型总结05GitHub 镜像站点06AI科技热点日报 | 2026年6月1日07AI一周事件 · 2026-06-03 至 2026-06-09082026 AI 编程工具终极实战指南:Cursor vs Claude Code vs Copilot,开发者该怎么选?09Claude Code、Codex、Cursor三分天下:2026年AI编程Agent生态全景剖析10上线仅72小时被强制下架:Claude Fable 5 的短命