lunes, 24 de octubre de 2011

Translations in Qt

I want to talk about a great feature in Qt, translations! I'm sure everyone have used a translated Software, as a Developer I was thinking how all that work, but I found how easy was to do it using Qt and I will explain it now.

First you need to add a line to your .pro indicating all translation you want, like this:

TRANSLATIONS = OrderMyPhotos_en.ts

Then you need to run the tool lupdate with your project file as a parameter.

lupdate project.pro

That generates the file OrderMyPhotos_en.ts

You have to open that using Qt Linguistic and start to translate, once you are done you have to run lrelease with your translated file

lrelease OrderMyPhotos_en.ts

That will generate OrderMyPhotos_en.qm

In order to use that you just have to do

QTranslator translator;
translator.load("OrderMyPhotos_en");
a.installTranslator(&translator);

And that's it, 

domingo, 16 de octubre de 2011

QSQL with SQLite

I've been trying to write a program that connects to a MySQL DB and a SQLite (I didn't found any script that converts a MySQL dump into SQLite, if you know one please let me know) In this post I just want to talk a little bit about the great QSQL

Using Qt you can write an app that connects to any of the most used DBMS like Oracle, MySQL, PostgreSQL, SQLite, and many others..The great thing about it it's that you define the database and if later you want to change to another one you can do it (that's great about the SQL standard).

I had a working example of an application that connects to a DB, it was using MySQL trough ODBC, and now with a little adjustment it uses QSQLite

    bd = QSqlDatabase::addDatabase( "QODBC" );
    bd = QSqlDatabase::addDatabase( "QSQLITE" );
 
at first I had to change the connection to QSQLITE, also the name of the database needs to
be updated 

        bd.setDatabaseName("DRIVER={MySQL ODBC 5.1 Driver};DATABASE="+nombreBD+";SERVER="+ubicacionBD);
        bd.setDatabaseName("ccomputo.sqlite");
 
With only those adjusments my application keeps working as it should..

martes, 4 de octubre de 2011

DownloadCounter - Almost 20,000

Almost 20,000 downloads for download counter, this show how a simple yet useful application can be downloaded many times.