I was trying to do a simple program sort of learning the ropes. I created a form, setup a database connection within project and did a browser that lists the phone number field and has a single button that says insert.
When i hit preview everything works like its supposed to.
So now i want to be able to compile it
First thing i found i needed to do was File->New->MainCPP and then choose my form.
Now it compiles but throws out tons of errors when i start the executable. So i found out that the program needs its own SQL connection, I went threw errors and errors of compiles but finally got it to compile with these additions to the main.cpp
Quote:
#include <qapplication.h>
#include <qsqldatabase.h>
#include <qdatatable.h>
#include <qsqlcursor.h>
#include "form1.h"
#define DRIVER "QMYSQL3"
#define DATABASE "qtmysql"
#define USER "root"
#define PASSWORD "mypassword"
#define HOST "gate"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
QSqlDatabase * defaultDB = QSqlDatabase::addDatabase( DRIVER );
defaultDB->setDatabaseName( DATABASE );
defaultDB->setUserName( USER );
defaultDB->setPassword( PASSWORD );
defaultDB->setHostName( HOST );
}
|
Thats all the code i have as the header file for the form is empty aside from one very long comment. when i compile everything starts without visual errors. but when starting from a command prompt i can see it cannot find the table within my qtmysql database. The table's name is ihldnc.
So my question is how do i get the qt stuff i inserted to use the sql connection that i have set up. I can't find any code relating to anything and im still learning the rope of ide's. I've exhausted nearly all the examples within the documentation. Any help would be appreciated.