QT创建按钮篇

QT创建按钮篇

1.概述

这篇文章从创建一个按钮对QT开发流程熟悉。

2.代码

c 复制代码
#include "mywidget.h"
#include <QPushButton>

myWidget::myWidget(QWidget *parent)
    : QWidget(parent)
{
//    第一种创建按钮方式
//    QPushButton *btn = new QPushButton();
//    btn->show();
//    btn->setParent(this);
//    btn->setText("button");

//    第二种创建按钮方式
    QPushButton *btn2 = new QPushButton("构造按钮",this);
//    调整按钮位置
    btn2->move(10,10);
//    设置窗口尺寸
    resize(600,400);
//    设置固定尺寸窗口
    setFixedSize(600,400);

//    设置窗口标题
    setWindowTitle("hello wold");
}

myWidget::~myWidget()
{

}
相关推荐
用户8055336980315 小时前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner16 小时前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz6 天前
QML Hello World 入门示例
qt
xcyxiner9 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner9 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner10 天前
DicomViewer (添加模型类)3
qt
xcyxiner10 天前
DicomViewer (目录调整) 2
qt
xcyxiner10 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR00612 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术12 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript