Nada De Interes

Páginas: 8 (1764 palabras) Publicado: 10 de abril de 2012
Qt Features and Programming with Qt
Qt Training - TAMK, 21.4.2009 Tony Torp (tony.torp@tamk.fi)

Lecturer
• Tony Torp, 33 • DI (ohjelmistotekniikka, tietoliikennetekniika), TTY 2000 • Historiikki • 1998 tuntiopettaja, ohjelmistotekniikka (TTY) • 1999-2002 Nokia Symbian/S60 • 2002-> ohjelmistotekniikan lehtori, TAMK • Työnkuva: projekteja (50%), kursseja ja päättötöitä(50%) ☺ • C++,olio-ohjelmointi, ohjelmistotuotanto, • Ohjelmistotekniikan projektityö, Ohjelmistotekniikan työkurssi • Tietoliikennetekniikan jatkokurssi, Tietoliikennetekniikan laboratoriotyöt, • Java 1, Java 2 • Symbian perus- ja jatkokurssit

Contents
1. 2. 3. 4. 5. 6. 7. 8. 9. Parents, Children and Memory Management Inter-object Communications Meta-object System Event Handling Mechanism Strings MultithreadingContainers and Algorithms Qt Module Walkthrough Qt Development Tools

How much C++ needed
• Objects and classes - Declaring a class, inheritance, calling member functions etc • Polymorphism - that is virtual methods • Operator overloading • Templates - for the container classes only. • No RTTI, no sophisticated templates, no exceptions thrown...

#include #include int main(int argc, char*argv[]) { QApplication app(argc, argv); QPushButton hello("Hello world!"); hello.resize(100, 30); hello.show(); return app.exec(); }

Contents
1. 2. 3. 4. 5. 6. 7. 8. 9. Parents, Children and Memory Management Inter-object Communications Meta-object System Event Handling Mechanism Strings Multithreading Containers and Algorithms Qt Module Walkthrough Qt Development Tools

QObject
• Baseclass for Qt objects providing
• • • • Signal/slot connections between any QObjects Object trees and object ownership (memory management) Event handling Run-time class and object information
• object name • class name • inheritance hierarchy etc.

• Timing services

• Qt meta-object system (and compiler) needed for gaining all these

Parent-Child Relationship
• When a QObject is created, itis given its parent as an argument QObject ( QObject * parent = 0 ) • The child informs its parent about its existence, upon which the parent adds it to its own list of children • For QWidgets: If parent is 0, the new widget becomes a window

int main(int argc, char *argv[]) { QApplication app( argc, argv ); QWidget top; QLabel *nameLabel = new QLabel("Username:", &top); QLineEdit *nameEdit =new QLineEdit(&top); QLabel *passLabel = new QLabel("Password:", &top); QLineEdit *passEdit = new QLineEdit(&top); QVBoxLayout *vlay = new QVBoxLayout(&top); QHBoxLayout *nameLayout = new QHBoxLayout; QHBoxLayout *passLayout = new QHBoxLayout; vlay->addLayout(nameLayout); vlay->addLayout(passLayout); nameLayout->addWidget(nameLabel); nameLayout->addWidget(nameEdit);passLayout->addWidget(passLabel); passLayout->addWidget(passEdit); top.show(); app.exec(); }

Memory management rules
• QObject derived classes are allocated on the heap using new • The parent takes ownership of the object so no explicit delete needed QPushButton* button = new QPushButton(”Ok”,parent); • Objects not inheriting QObject are allocated on the stack QColor color(100,12,100); QString greeting(”Hello Qt”); •Exceptions • QApplication and QFile are allocated on the stack

Parent’s responsibilities
• Deletes all children when it is deleted itself
• But does not set your own possible pointers to those objects to NULL! • The parent is informed if a child is deleted manually

• Hides/shows the children when it is hidden/shown itself • enables/disables the children when it is enabled/disabled itself Is this ok?
int main( int argc, char* argv[] ) { QApplication myApp( argc, argv ); QLabel myLabel(”My text”); QWidget window; myLabel.setParent(&window); window.show(); myApp.exec(); }

Contents
1. 2. 3. 4. 5. 6. 7. 8. 9. Parents, Children and Memory Management Inter-object Communications Meta-object System Event Handling Mechanism Strings Multithreading Containers and Algorithms Qt Module...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Nada de interes
  • Nada de interes
  • Nada de interes
  • Jajajajja ke tontos x inter no konsigen nada
  • Interes
  • Interes
  • Interes
  • INTERES

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS