1、MySQL驱动安装
Qt5.13版本及之后的版本默认不带有MySQL驱动。在这些版本中,如果需要连接MySQL数据库,开发者通常需要自行编译MySQL驱动或者从其他渠道获取已编译的驱动文件,查看MySQL驱动是否安装
新建控制台项目.pro工程文件内容如下
QT += core sql
CONFIG += c++17 cmdline console
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
msvc {
QMAKE_CFLAGS += /utf-8
QMAKE_CXXFLAG