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 @ 2022-04-30 11:19  liankewei123456  阅读(124)  评论(0编辑  收藏  举报