Unsando Qt En C++

Solo disponible en BuenasTareas
  • Páginas : 4 (811 palabras )
  • Descarga(s) : 0
  • Publicado : 1 de octubre de 2012
Leer documento completo
Vista previa del texto
T H E U N I V E R S I T Y of T E X A S
HEALTH SCIENCE CENTER AT HOUSTON
S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S

Using C++ and Qt in Practice
For students of HI 5323“Image Processing”
Stefan Birmanns, Ph.D.
School of Health Information Sciences
http://biomachina.org/courses/processing/04.html

Outline
1.
2.
3.
4.
5.
6.
7.

Files (.cpp, .h)Preprocessor, Compiler, Linker
Shared Libraries
Makefiles and Qmake
Qt
Qt Designer
Demo

File Types
• .cpp, .c – Source code files
Definition of your program
int funcA(int i)

Definition

{return 5*i;
}
int funcA(int i);

Declaration

Before using a function/class you need to declare or define it
int i;
extern int i;

Definition
Declaration

Modules
Use multiple .cpp/.c filesto group functions and classes into modules

-

E.g. “fileio.c filter.c display.c”

Code is easier to understand, easier to locate functions, etc.
Compilation time gets reduced

-

Only thechanged module needs to get recompiled
Works only if no dependencies between modules exist


If one changes the interface of module A, also the other modules need to
get recompiled

Module Aneeds to know about functions/classes provided by Module B

-

Header files

Every class/function/object can only get defined once!

Definitions
• One time definition rule:
Everyclass/function/object must be defined only once!
File fileio.c
int x;
File filter.c
float x; // error! X already defined
extern int x; // ok, just declaration
extern float x; // error! wrong type
intfuncA() { float x; } // ok, different scope
class clA
{
float x; // also ok, different scope
}

File Types
• .h – Header files
Define a common interface between all modules
Function and classdeclarations

-

int funcA(int i);
class B { B(int i); }

But no definitions!

-

int funcA(int i){ return i*5; }
int global_i;

// not in .h!

// not in .h!

Everything can only...