Qt编程---按钮操作

Qt编程---开始

 

这学期程设有个 qt 的大作业,利用五一自学一下~

非常颓废,现在是五一最后一天了,开始学...

 

命名规范:

类名:首字母大写,驼式命名

函数名、变量名:首字母小写,驼式命名

 

快捷键

运行 ctrl + r

编译 ctrl + b

自动对齐 ctrl + i

切换.h .cpp F4

widget

main.cpp

#include "hello.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    hello w;
    w.show();
    return a.exec();
}

 

按钮操作

#include "hello.h"
#include "ui_hello.h"
#include <QPushButton>
hello::hello(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::hello)
{
    QPushButton *btn = new QPushButton;
    btn -> setParent(this);// 依赖在当前窗口下
    btn -> setText("你好");
    
    //重置窗口大小
    resize(600,400);
    
    //窗口标题
    setWindowTitle("just note");
    ui->setupUi(this);
}

hello::~hello()
{
    delete ui;
}

 

posted @   liankewei123456  阅读(135)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示