I would like to know why I am getting these errors. I am using Qt 5.0.2 and MSVC-2010 compiler. It normally runs when I delete the blah function. I am not an expert programmer, please answer me like I do not know anything, thank you!
Error:
My code below:
.pro login.cpp main.cpp Edit: I did include QT + = sql and # 0, but now I get this error. Error: error message says that the linker QT + = core GUI QT + = widget QT + = Network mostly (QT_MAJOR_VERSION, 4): QT + = widgets target = Guangdong template = app source = + main.cpp \ login. Cpp Headers + = login.h form + = login.ui
# include "login.h" #include "ui_login" Include #include & quot; QtSql / QSql & gt; # & quot; QtSql / QSqlDatabase & gt; # Include & lt; QDebug & gt; # Include & lt; Query.h & gt; # Include & Lt; qstring & gt; Include & lt; QtSql / QSqlQuery & gt; # Include & lt; QtNetwork / QNetworkInterface & gt; Login :: login (QWidget * parent): QMainWindow (parent), UI (new UI: : Login) {UI-> setupUi (this); blah ();} login :: ~ login () {delete ui;} zero login :: blah () {// QSqlQuery query; QSqlDatabase db = QSqlDatabase :: AddDatabase ("QMYSQL"); db.setHostName ("blah"); db.setDatabaseName ("blah"); db.setUserName ("blah"); db.setPassword ("bla H "); bool ok = db.open (); if (okay) {ui-> label-> set-test (" doppop "); db.close ();} and ui- & gt; label - & gt; Settext ("Opening error");}
#include "login.h" # Include & lt; QApplication & gt; Int main (int argc, char * argv []) {Q Application A (argc, argv); Login w; W.show (); Back to a.exec (& amp; # 41 ;;
external symbols is the header
& lt; QtSql can not be defined in / QSqlQuery> You need to link against the
QtSql library / module:
QT + = core GUI QT + = widget QT + = Network QT + = Sql Mostly (QT_MAJOR_VERSION, 4): QT + = VS Gates target = Guangdong template = app source + = main.cpp \ login.cpp headers + = login.h form + login.ui
No comments:
Post a Comment