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.


miércoles, 21 de septiembre de 2011

Extras-Testing


I Finally got the link to promote my package, the description was missing so even the time was enough the link didn't showed up until today that I fixed the description, so DownloadCounter is in Extras Testing now :D


How to know the SQL Drivers available

In order to comunicate with a database in Qt you need the propper driver, if you want to know what drivers are available for you, you can exec this:

qDebug()<< "Availables drivers are: \n"+QSqlDatabase::drivers().join(" \n ");



Of course you need qDebug, QSqlDatabase and QtSQL in your headers.

Qt SQLite 1 - Initialize and Connect

In order to connect Qt and SQLite you have to compile the SQLite drivers (in other entry I'll talk about it)

You need to include in you headers

#include <QtSql>
#include <QSqlDatabase>
 
Then in order to initialize the DB you have to give
the driver's name to addDatabse, in this case the driver's name is
"QSQLITE"
void Queries::initDB(){
    db = QSqlDatabase::addDatabase( "QSQLITE" );
    sql = QSqlQuery  (db);
}
Then to connect and query the database you have to do something like this

bool Queries::connectDB(){
    db.setDatabaseName("db.sqlite");


    if (!db.isValid()){
       QMessageBox::critical(0,"Conecction unsuccesful" 
                              ,"<b>Problems</b>:"+db.lastError().text(),
                              QMessageBox::Ok);
        exit(0);

    }
    if (!db.open()){
        QMessageBox::critical(0,"Not connected",
                              "<b>Problems</b>: The database does not exist",
                              QMessageBox::Ok);
        return false;
    }else{

        sql.clear();
        QString strSql = "CREATE  TABLE 
                          IF NOT EXISTS \"main\".\"Users\" (\"user_id\"  
                          INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , \"user\" 
                          CHAR NOT NULL , \"password\" CHAR NOT NULL )";
        sql.prepare(strSql);
        if( !sql.exec() ){
            showError(sql.lastError().text());
            exit(0);
        }else{
            strSql = "INSERT INTO Users (user,password) VALUES ('test','test')";
                    sql.prepare(strSql);
                    if( !sql.exec() )
                        showError(sql.lastError().text());
                    else{
                        if (sql.first())
                            {
                                qDebug() << sql.value(0).toString();
                            }
                    }

        }

        return true;
    }
}

martes, 13 de septiembre de 2011

Maemo bugtracker

Uno de los requisitos para alcanzar estar en los repositorios Extras es tener un link a donde pueden registrar bugs encontrados en tu programa, para realizar esto podemos solicitar un nuevo item en el bugzilla o si es una aplicación pequeña podemos dar un correo electrónico, para hacer eso se debe modificar el archivo control y agregarle una linea como la siguiente..

XSBC-Bugtracker: mailto:yourname@example.com
 
Help me! I wan't to be in Extras repository! 

domingo, 11 de septiembre de 2011

How to develop a Qt app for Maemo and Desktop

If you have developped an app for Maemo and then you want to deploy it on desktop (or backwards) you may have found that it looks weird, that's mainly for two reasons, first of all Qt for desktop (X11, Windows or MAC) renders widgets diferent from Qt for Maemo, also tmaemomaemohe resolution is something to have in mind, the N900 is 480x800 or 800x480 (depends on how you look at it).. and it's just 3.5" so you have to make everything bigger for easy reading..

If you are like me and you use Qt Designer to create your UI you may have run into trouble when targetting both desktop and mobile platforms, one solution (I don't know if it's the best) is to create another class for your mainwindow, so you have 2 (maybe if you targett 4 diferent platforms this isn't any good) classes, MainWindowDesktop and MainWindowMaemo, then you define your UI using Qt Designer, then you can make an specific desing for maemo and another for desktop, this saves you some trouble but the disadvantage is that you have to "write" te code twice (Of course you can copy and paste). If you have another idea don't hesitate to say it..

In main.cpp you have to write something like this

#ifdef Q_WS_MAEMO_5
    MainWindowMaemo mainWindowMaemo;
    mainWindowMaemo.setOrientation(MainWindowMaemo::ScreenOrientationAuto);
    mainWindowMaemo.showExpanded();
#else
    MainWindowDesktop mainWindowDesktop;
    mainWindowDesktop.show();
#endif

I hope you find it useful :D

sábado, 10 de septiembre de 2011

Uploading to Extras Devel

Para subir a los repositorios Extras Devel se debe crear una cuenta en Garage Maemo


Así que pueden dirigirse a https://garage.maemo.org/ y crear una cuenta, una vez hecho eso ya podrán iniciar sesión en


https://garage.maemo.org/extras-assistant/

Si les sale un mensaje diciendo que no tienen permisos, primero deben enviar la solicitud diciendo el nombre del paquete que desean subir.

Allí deben subir el archivo .changes de su paquete, después de hacerlo se pide el
.dsc y el .tar.gz

Al tener todo esto y enviar el archivo al autobuilder ya está listo, toca esperar a ver si el paquete es generado correctamente.

Repositorios Maemo

La aplicación que hice muestra las descargas de un paquete de los repositorios Extras, así que ahora toca hablar de estos repositorios.

Para instalar aplicaciones en el N900 podemos optar por utilizar la OVI Store o los repositorios que la comunidad ha creado y mantenido, alli podemos encontrar aplicaciones original y ports de aplicaciones de escritorio como el cliente de mensajeria instantanea pidgin.

A continuación un fragmento de los repositorios Extras-Devel

Developers upload the newest version of their software to extras-devel. From there the packages go Extras-testing and finally Extras through an automatic and human Quality Assurance process. This is a repository for developers and regular contributors of specific software projects. If you want to play with extras-devel software you need to be prepared to feel some pain sooner or later. 

From http://wiki.maemo.org/Extras-devel

En la siguiente entrada hablaré de mi experiencia subiendo la aplicación a los repositorios.

Download Counter

 Les presento mi primer aplicación para maemo, se llama Download Counter y muestra la cantidad de veces que un paquete de los repositorios Extras se ha descargado..

Se debe indicar el nombre del paquete y dar click al botón search

Lo cual consultará la información y nos la mostrará en pantalla


Espero sus comentarios!
Aquí les presento mi proyecto "DownloadCounter", pretende ser una aplicación que servirá para contar precisamente cuantas descargas se hacen de una aplicación.. Espero les guste y les sea muy útil.

Gracias por su interés




Maemo

Qué es Maemo?

Maemo es una plataforma basada en su mayoría en software libre, maemo se encuentra en dispositivos moviles como el N900, a continuación un fragmento de la definición oficial.

Maemo is a software platform that is mostly based on open source code and powers mobile devices such as the Nokia N810 Internet Tablet. Maemo platform has been developed by Nokia in collaboration with many open source projects such as the Linux kernel , Debian , GNOME , and many more.



From http://maemo.org/intro/

miércoles, 7 de septiembre de 2011

What is Qt?

 Taken From http://qt.nokia.com/

Qt es un framework multiplataforma de desarrollo de aplicaciónes e interfaces gráficas.  Incluye herramientas de desarrollo y un IDE multiplataforma. Con Qt (se pronuncia como cute, he de alli el nombre del blog) puedes escribir aplicaciones una vez y compilarlas y distribuirlas en diferentes sistemas operativos sin modificar el código.

Aquí el diagrama:
Diagram - Product Architecture Graphic

Presentación

Hola soy JessyNay y este es mi blog sobre Qt, estoy aprendiendo y aqui escribiré sobre mi experiencia utilizandolo. Se aceptan preguntas y comentarios.