Qt for Diseño de Sistemas Informaticos Industriales


1. Introduction
2. Step 1: Read ...
3. Step 2: A "Hello world" in Qt creator
4. Step: Test the debugger
5. Step: I will explain pointers and practice it with the Qt Creator IDE
6. Step: I will explain some basics of C++
7. Step: The first Qt-based GUI APP. Hello Qt!

1. Introduction

Qt could be wonderful for developing cross-platform C++ GUI applications.

This is my firt attempt to transfer this posibility to my students and it is a simple guide for my steps.

2. Step 1: Read ...

Read carefully the "Tour rápido de Qt Creator" that you will easily find when you run the Qt Creator.

3. Step 2: A "Hello world" in Qt creator

I propose a a first contact with the "Qt creator" IDE trying to write and run a typical "Hello program" for the C program.

First, we need to create a project. Follow steps on next figure to acces to this option:

Figure 1. Steps for creating a project

Steps for creating a project

Now you must select the type of project to be created. There are few options, and all related to Qt project creation.

It seems that te best option for a C generic program is to select the item marked in the next image and to modify it.

Figure 2. New project dialog

New project dialog

You wiil be asked for a name for the project and a directory for putting files. You should create a new directory on some place to place these files.

After this step, you will be asked for the modiules to be included in the project. Do not change anything.

After creating the project you will enter in the edition mode. You can access a main.cpp file with the following code:

#include <QtCore/QCoreApplication>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    return a.exec();
}

Hummm, probably you do not understand too much, but you can appreciate an standard C program.

Well, let me to convert it to our well known "Hello world" for the C language.

//#include <QtCore/QCoreApplication>
#include <stdio.h>

int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);
    printf("Hello, world!!!! ... Qt is near!\n");
    getchar();

    //return a.exec();
    return(0);
}

And runt it. You should know how to do that beacuse you read the seguested previous sections and tutorials.

4. Step: Test the debugger

To continue playing with the environment, I suggest to try to debug a program (break points, step-by-stp, ...).

Modify the previous example, adding the following code:

//#include <QtCore/QCoreApplication>
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i;

    //QCoreApplication a(argc, argv);

    printf("Hola Mundo\n");

    for (i=0; i<100;i++) {
        printf("i vale %d\n",i);
    }

    getchar();

    //return a.exec();
    return(0);
}

Build the application and put a breakpoint in the loop and play with the debugger (using left button marked with a bug). You could get a view similar to this one:

Figure 3. View of the debugger in action

View of the debugger in action

5. Step: I will explain pointers and practice it with the Qt Creator IDE

Ficar enllaç per descarregar apunts.

6. Step: I will explain some basics of C++

Enllaç apunts.

7. Step: The first Qt-based GUI APP. Hello Qt!