yes, I was install Qt from synaptic install manager
I install all package but mysql.pro is not present
and I have qt4 and qt3, can this make problems
yes, I was install Qt from synaptic install manager
I install all package but mysql.pro is not present
and I have qt4 and qt3, can this make problems
I have look in synaptic and I have Qt mysql driver, it is installed at my Ubuntu
Qt4 Mysql database driver - this is name of synaptic package
So, you don't need to rebuilt Qt MySQL driver. Try to create simple application using MySQL driver.
Last edited by saa7_go; 24th July 2010 at 21:55. Reason: updated contents
I try to create simply application Qt and Mysql
and there I find some unexpected problems.
I make one project on C not C++, and it work, but this is not from QT, simply C code from gedit and gcc
I have one project in QT
one file is
connector.h
Qt Code:
#ifndef CONNECTOR_H #define CONNECTOR_H #include <QSqlDatabase> #include <QMessageBox> bool createConnection() { { db.setHostName("localhost"); db.setDatabaseName("test"); db.setUserName("user"); db.setPassword("pass"); if (!db.open()) { QMessageBox m; m.setText("Greska I"); m.exec(); return false; } else { return true; } } else { QMessageBox m; m.setText("Nema drajver za DB"); m.exec(); return false; } } #endif // CONNECTOR_HTo copy to clipboard, switch view to plain text mode
and main.cpp
Qt Code:
#include <QtGui/QApplication> #include "mainwindow.h" #include "connector.h" int main(int argc, char *argv[]) { if(!createConnection()) return 1; MainWindow w; w.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
and this project not work at QT
Are there any error/warning messages from your application?
I have this errors:
Qt Code:
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3: /home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3: /home/miroslav/dekis/Dekis/connector.h:11: error: expected ‘;’ before ‘db’ /home/miroslav/dekis/Dekis/connector.h:12: error: ‘db’ was not declared in this scope /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’ /home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scope /home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’To copy to clipboard, switch view to plain text mode
Can you post/attach your mainwindow.h and project file (*.pro)?
It looks like you don't add sql module in your project file.
mainwindow.h
Qt Code:
/**************************************************************************** ** Form interface generated from reading ui file 'mainwindow.ui' ** ** Created: Sat Jul 24 19:27:05 2010 ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/To copy to clipboard, switch view to plain text mode
Dekis.pro
Qt Code:
###################################################################### # Automatically generated by qmake (2.01a) Tue Jul 20 19:42:45 2010 ###################################################################### TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . # Input HEADERS += connector.h mainwindow.h FORMS += mainwindow.ui SOURCES += main.cpp mainwindow.cppTo copy to clipboard, switch view to plain text mode
Where is your MainWindow class declaration?
Add the the following line in Dekis.pro
I was not make changes in MainWindow class declaration.
after I add
to Dekis.pro
I have next errors (it is less then before)
Qt Code:
/home/miroslav/dekis/Dekis/main.cpp:3: In file included from main.cpp:3: /home/miroslav/dekis/Dekis/connector.h:11: error: expected primary-expression before ‘.’ token /home/miroslav/dekis/Dekis/main.cpp:12: error: ‘MainWindow’ was not declared in this scope /home/miroslav/dekis/Dekis/main.cpp:12: error: expected ‘;’ before ‘w’ /home/miroslav/dekis/Dekis/main.cpp:13: error: ‘w’ was not declared in this scopeTo copy to clipboard, switch view to plain text mode
miroslavgojic (28th July 2010)
Bookmarks