当前位置: 首页 > news >正文

QT学习与数据库连接

1.基础

   1. 安装最后一个非在线版本 5.14,

       没有的话联系我 

         新建一个.cpp文件

#include <QApplication>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QWidget>
int main(int argc, char *argv[ ])
{QApplication app(argc,argv);QLabel  *infoLabel=new QLabel;QLabel  *openLabel=new QLabel;QLineEdit  *cmdLineEdit=new QLineEdit;QPushButton  *commitButton =new QPushButton;QPushButton  *cancelButton =new QPushButton;QPushButton  *browseButton =new QPushButton;infoLabel->setText("input");openLabel->setText("open");commitButton->setText("commit");cancelButton->setText("cancel");browseButton->setText("browse");
QHBoxLayout  *cmdLayout=new QHBoxLayout;
cmdLayout->addWidget(openLabel);
cmdLayout->addWidget(cmdLineEdit);
QHBoxLayout  *buttonLayout=new QHBoxLayout;
buttonLayout->addWidget(commitButton);
buttonLayout->addWidget(cancelButton);
buttonLayout->addWidget(browseButton);
QVBoxLayout  *mainLayout=new QVBoxLayout;
mainLayout->addWidget(infoLabel);
mainLayout->addLayout(cmdLayout);
mainLayout->addLayout(buttonLayout);
QWidget w;
w.setLayout(mainLayout);
w.show();return app.exec();
}

2.添加环境变量

命令行界面:

   

生成工程文件

     1)qmake  -project

     进入工程目录,也就是cpp所在文件夹,执行qmake  -project

    下文中的pro后缀代表project

        

    注意此时需要打开该文件添加行QT+=widgets gui

       

######################################################################
# Automatically generated by qmake (3.1) Mon Sep 16 08:56:09 2024
######################################################################TEMPLATE = app
TARGET = qt1
INCLUDEPATH += .# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0# Input
SOURCES += qmake.cppQT+=widgets gui

    2)qmake

   再执行 qmake,每次修改文件之后可以直接执行qmake

  

   3)mingw32-make

       因为在windows环境,再执行mingw32-make,如果是linux环境直接执行make

QT+=gui widgets

      release文件夹就会出现,也就可以了

http://www.lryc.cn/news/439684.html

相关文章:

  • 泛读笔记:从Word2Vec到BERT
  • redis实现分布式锁详细教程,可续锁(看门狗)、可重入
  • 代码随想录打卡Day32
  • 数学学习记录
  • R语言统计分析——散点图1(常规图)
  • 蓝桥杯—STM32G431RBT6按键的多方式使用(包含软件消抖方法精讲)从原理层面到实际应用(一)
  • 基于STM32的温度、电流、电压检测proteus仿真系统(OLED、DHT11、继电器、电机)
  • Linux - iptables防火墙
  • 【C语言零基础入门篇 - 3】:格式化输入输出、字符操作和sizeof运算符揭秘
  • JVM字节码与局部变量表
  • Java许可政策再变,Oracle JDK 17 免费期将结束!
  • 网页交互模拟:模拟用户输入、点击、选择、滚动等交互操作
  • C sharp 学习 笔记
  • 文章资讯职场话题网站源码整站资源自带2000+数据
  • c++ templates常用函数
  • 【重学 MySQL】三十一、字符串函数
  • 828华为云征文 | 使用Flexus云服务器X实例部署GLPI资产管理系统
  • 深入理解Go语言的面向对象编程、Git与GitHub的使用
  • redis底层—通信协议RESP
  • JVM 调优篇6 可视化性能监控工具-JVisual VM
  • C#学习笔记(三)Visual Studio安装与使用
  • element-plus的菜单组件el-menu
  • 深入浅出通信原理
  • Gitee Pipeline 从入门到实战【详细步骤】
  • 【贪心算法】贪心算法
  • 【网络原理】❤️Tcp 常用机制❤️ —— 延时应答,捎带应答, 面向字节流, 异常情况处理。保姆式详解 , 建议收藏 !!!
  • Scratch教学案例 —— 制作生日蛋糕
  • 【深度学习】搞懂卷积神经网络(一)
  • VisionPro - 基础 - 00 模板匹配技术和在VP中的使用 - PMAlign - PatMax - (上)
  • 容器镜像同步工具image-migrator