On OS with installed QT – everything works. But if QT not installed – i see some bugs…
Programm can’t view plugins and crashed with runtime error if the creation of the base is in a separate class CDatabase. If the content CDatabase :: CDatabase i moved to MainWindow :: MainWindow – everything works. Any ideas?
OS: Windows XP / Windows 7 ×64
Full source code (failed on OS without QT): http://pastebin.com/6Q2Jtn57
Full source code (working on all OS): http://pastebin.com/C8KfZ1NB
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "cdatabase.h"
CDatabase db;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
cdatabase.h
#ifndef CDATABASE_H
#define CDATABASE_H
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QString>
class CDatabase
{
public:
CDatabase();
private:
QSqlDatabase db;
};
#endif // CDATABASE_H
cdatabase.cpp
#include "cdatabase.h"
CDatabase::CDatabase()
{
QString connection = QString(QSqlDatabase::defaultConnection);
if (QSqlDatabase::contains(connection)) {
db = QSqlDatabase::database(connection);
} else {
db = QSqlDatabase::addDatabase("QSQLITE", connection);
db.setDatabaseName("db.sqlite");
db.open();
}
}
main.cpp, mainwindow.h, wolqru.pro – not important. For source code see link above.
List of files in program dir:
platforms\qwindows.dll
platforms\qminimal.dll
sqldrivers\qsqlite.dll
wolqru.exe
Qt5Core.dll
libgcc_s_sjlj-1.dll
libstdc++-6.dll
libwinpthread-1.dll
Qt5Widgets.dll
Qt5Sql.dll
Qt5Gui.dll
libGLESv2.dll
libEGL.dll
icuin49.dll
icuuc49.dll
icudt49.dll
D3DCompiler_43.dll
↧