Qt day1

1.思维导图

2.创建按钮

复制代码
#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    //创建第一个按钮
    QPushButton *btn1=new QPushButton ;

    //组件使用show函数,只会独立显示
    //btn1->show();

    //让按钮1依赖窗口显示,给按钮1指定一个父对象
    btn1->setParent(this);
    //按钮设置文本
    btn1->setText("第一个按钮");
    //设置背景颜色
    btn1->setStyleSheet("background-color:pink");

    //创建第二个按钮
    QPushButton *btn2=new QPushButton("第二个按钮",this);
    //按钮移动
    btn2->move(55,55);
    //设置图标
    btn2->setIcon(QIcon("‪C:\\Users\\Precision 7720\\Desktop\\pictrue\\passwd.jpg"));

    //创建第三个按钮
    QPushButton *btn3=new QPushButton(QIcon("‪C:\\Users\\Precision 7720\\Desktop\\pictrue\\passwd.jpg"),"第三个按钮",this);
    //移动
    btn3->move(100,100);
    //重新设置大小
    btn3->resize(120,60);
    //设置不可用
    btn3->setEnabled(false);

}

MyWidget::~MyWidget()
{
}
相关推荐
Y3815326626 小时前
2026 年 7 月,SERP API 调用的稳定性实战:超时、重试、降级
开发语言·数据库·人工智能·php
sugar__salt6 小时前
向量数据库从零到实战:用 Milvus + Zilliz 构建 AI 日记语义检索系统
数据库·人工智能·embedding·milvus·rag·zilliz
Gauss松鼠会6 小时前
Prometheus 实现 openGauss 的指标监控(二)Prometheus 中添加 openGauss指标
网络·数据库·oracle·prometheus·opengauss·经验总结
Cloud云卷云舒7 小时前
PolarDB(阿里云)VS HaishanDB(海山数据库,移动云)的AI能力全面对比
数据库·阿里云·ai-native·polardb·haishandb
我是人✓7 小时前
SQL主键与外键
java·数据库
飞翔的馒7 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
数据库·缓存
SelectDB7 小时前
SelectDB search():AI 日志搜索与分析场景的技术能力与实践
数据库
SelectDB7 小时前
Apache Doris 事务保障:技术能力、选型对比与企业实践
数据库
SelectDB7 小时前
AI Observe Stack(基于 Apache Doris):AI Agent 可观测性技术能力、选型对比与实践
数据库