19,502
社区成员
发帖
与我相关
我的任务
分享
#include "widget.h"
#include <QApplication>
#include<QtSql/QSqlDatabase>
#include<QtSql/QSqlQuery>
extern "C"{
#include "stdio.h"
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QSqlQuery query;
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("192.168.12.95");
db.setDatabaseName("finger");
db.setUserName("finger");
db.setPassword("qrszwxt");
db.setPort(3306);
if(db.open())
{
w.show();
printf("successful!!!\n");
}else{
printf("lianjie failed!\n");
}
return a.exec();
}
#-------------------------------------------------
#
# Project created by QtCreator 2018-12-27T16:07:30
#
#-------------------------------------------------
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled10
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# 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
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
FORMS += \
widget.ui
您好,您的问题解决了吗