In my application I am using a QSqlDatabase to store some information. I did built it successfully with the following command (no errors even with verbose=3
):
macdeployqt AppName.app/ -dmg -qmldir=~/dev/AppName/qml
Before that I successfully installed mysql55 using port
sudo port install mysql55
If I try to run my application it does not crash, but it also does not anything which involves database access.
This is my code for opening a database etc:
#include <QSqlQuery>
#include <QSqlDriver>
const QString DATABASE_NAME = "com.company.program.db";
MyClass::MyClass(QObject *parent) : QObject(parent) {
mDB = QSqlDatabase::addDatabase("QSQLITE");
#ifdef Q_OS_LINUX
QString path(QDir::home().path());
path.append(QDir::separator()).append(DATABASE_NAME);
path = QDir::toNativeSeparators(path);
mDB.setDatabaseName(path); // NOTE: We have to store database file into user home folder in Linux
#else
mDB.setDatabaseName(DATABASE_NAME); // NOTE: File exists in the application private folder, in Symbian Qt implementation
#endif
bool notOpened = !mDB.open();
QMessageBox::critical(0, "MyClass", mDB.lastError().databaseText()); // always is 'out of memory'
if (notOpened) emit failedToOpen();
else {
// some initialization
}
}
MyClass::~MyClass() {
mDB.close();
}
Has anyone experienced the same issues / a fix for this one?
Note: I am using Mac OS X 10.9 and Qt5.3.2
I managed to fix the out of memory
error by executing this code:
#ifdef Q_OS_MAC
QString databaseName = QApplication::applicationDirPath().append("/").append(DATABASE_NAME);
mDB.setDatabaseName(databaseName);
#endif