PDA

View Full Version : Some questions on porting apps to Window$



jiveaxe
2nd November 2007, 14:25
Hi everybody,
new day new questions; cause some people are yet using gates' OS i am porting my application to this; since my application is 100% QT4.3 dipendent I have downloaded QT/Windows Open Source Edition (http://trolltech.com/developer/downloads/qt/windows) (self-extracting installer).

Then I have recompiled my source; from my experience here are my questions:

Who explains me this strange behaviour?
The folloeing code:

#include <QtGui>
#include <QSqlDatabase>
#include "maindialog.h"

QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

MainDialog::MainDialog(QWidget *parent)
:QDialog(parent)
{
...
if(!createConnection())
return;
...
}

bool MainDialog::createConnection()
{
db.setDatabaseName(QApplication::applicationDirPat h() + "/gmc_db");
if (!db.open()) {
QMessageBox::critical(0, qApp->tr("Cannot open database"),
qApp->tr("Unable to establish a database connection.\n"
"This program needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
return true;
}

gives error during execution on db.open() (as it can't find the database file, while it exist and is in the same directory as the exe).

If I move, instead, the row


QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

in createConnection() function it works good (in linux works in both situations).

The aspect of the text in the windows version is worst than in linux; it appears bigger and aliased; why? Is related to windows itself or to qt libraries?

If I have this code:


QFont Strings::totalscoreFont()
{
QFont font;
font.setStyleStrategy(QFont::PreferAntialias);
font.setStyleStrategy(QFont::ForceOutline);
font.setPixelSize(60);
font.setBold(true);
font.setFamily("Monofonto");

return font;
}

How can i change it so during compilation under windows it uses different fontfamily and size?

If i want give the compiled exe to my friends they need qt4.3 installed, doesn't they? Or can I include some qt's dll with my code (my application will be licensed under GPL).


Thanks for helping me,

jacek
2nd November 2007, 14:52
If I move, instead, the row


QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

in createConnection() function it works good (in linux works in both situations).
You shouldn't create any Qt objects before you instantiate QApplication (or QCoreApplication). In this case it doesn't work, because you try to use the QSQLITE driver before it was loaded by QApplication. On Linux it probably works, because you have this driver compiled into Qt.


font.setFamily("Monofonto");
Are you sure that this font is available on windows? If not Qt will use a different one.


How can i change it so during compilation under windows it uses different fontfamily and size?
You can use Q_OS_WIN32 macro.


If i want give the compiled exe to my friends they need qt4.3 installed, doesn't they? Or can I include some qt's dll with my code (my application will be licensed under GPL).
They don't have to install anything, just give them all required DLLs and plugins.

http://doc.trolltech.com/4.3/deployment.html
http://doc.trolltech.com/4.3/deployment-windows.html

jiveaxe
2nd November 2007, 15:15
You can use Q_OS_WIN32 macro.

Is this right?


QFont Strings::totalscoreFont()
{
QFont font;
font.setStyleStrategy(QFont::PreferAntialias);
font.setStyleStrategy(QFont::ForceOutline);
font.setBold(true);
#ifdef Q_OS_WIN32
font.setPixelSize(60);
font.setFamily("Verdana");
#else
font.setPixelSize(50);
font.setFamily("Monofonto");
#endif

return font;
}

Have I to modify also the .pro file?


They don't have to install anything, just give them all required DLLs and plugins.

So in my case I have to add to my package QtCore4.dll, QtGui4.dll, QtSql4.dll, right?

Regards

jacek
2nd November 2007, 15:30
Is this right?
It looks OK.


Have I to modify also the .pro file?
No, you don't have to.


So in my case I have to add to my package QtCore4.dll, QtGui4.dll, QtSql4.dll, right?
And a sqldrivers subdirectory with QSQLITE driver.

jiveaxe
2nd November 2007, 16:12
And a sqldrivers subdirectory with QSQLITE driver.

Which should be libqsqlite4.a, qsqlite4.dll.

Ok, understood.

Thanks

jacek
2nd November 2007, 16:26
Which should be libqsqlite4.a, qsqlite4.dll.
You only have to deploy the DLL file.

jiveaxe
2nd November 2007, 16:35
Ok, now it's all clear.

Bye