QT入门笔记

首先建立空项目文件,建立好之后创建C++源文件,通常取名为main,然后在project中添加一句

QT += widgets gui

接着在main函数中编程

Hello world

#include<QApplication>
#include<QWidget>
int main(int argc, char* argv[]){
    QApplication app(argc, argv);
    QWidget w;
    w.setWindowTitle("Hello World");
    w.setFixedSize(600,600);
    w.show();
    return app.exec();
}

Button

#include<QApplication>
#include<QWidget>
#include<QPushButton>
int main(int argc, char* argv[]){
    QApplication app(argc, argv);
    QWidget w;
    QPushButton button;
    button.setText("Press");
    button.setGeometry(150,150,100,80);
    button.setStyleSheet("background-color: rgb(0,255,255)");
    //button.setStyleSheet("color: red");
    button.setParent(&w);
    QObject::connect(&button,SIGNAL(clicked()),&w,SLOT(close()));
    w.setWindowTitle("Hello World");
    w.setFixedSize(400,400);
    w.show();
    return app.exec();
}

Login System

全部评论

相关推荐

零OFFER战士:另一个版本查看图片
点赞 评论 收藏
分享
zYvv:双一流加大加粗再标红,然后广投。主要是获奖荣誉不够,建议开始不用追求大厂,去别的厂子刷下实习。
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务