LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-01-2004, 04:38 PM   #1
sio
Member
 
Registered: Jul 2003
Location: Louisiana, US
Distribution: Slackware
Posts: 129

Rep: Reputation: 15
QT 3.3.2 & MySQL 4.0.20


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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware guide for AMP Apache MySQL & PHP xushi Slackware 35 05-11-2006 11:18 AM
Postfix & MySQL & POP3 on Redhat.. hct224 Linux - Newbie 0 05-20-2004 03:15 PM
From RedHat9 to FreeBSD (Apache 2 & Mysql & PHP 4) guardian653 *BSD 5 12-11-2003 05:31 PM
Apache & PHP & Mysql thomas050682 Linux - Networking 5 03-03-2003 03:21 PM
Apache & Php & MySql te_conway Linux - Software 2 12-21-2001 04:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration