23
QT Intro. 김김김 (kkhsoft@sparc s.org) http://kkhblog.spa rcs.net

QT Intro. 김기형 ([email protected])

Embed Size (px)

Citation preview

Page 1: QT Intro. 김기형 (kkhsoft@sparcs.org)

QT Intro.

김기형 ([email protected])

http://kkhblog.sparcs.net

Page 2: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 2/23

GUI in Linux

Page 3: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 3/23

GUI in Linux

Page 4: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 4/23

Program by QT

Page 5: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 5/23

What is QT?

• Especially, for GUI progrmming– For database, networking, XML, OpenGL, etc.

• Cross Platform

Qt is a comprehensive C++ application development framework. It includes a class library and tools for cross-platform development and internationalization.

Page 6: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 6/23

What is QT?

• “Write Once, Run Everywhere”

• Open Source– Free in Linux, Unix (

http://www.trolltech.com/download/qt/x11.html)– Free in both Windows and Mac recently (http://

www.trolltech.com/download/qt/windows.html)

• QPL(Q Public License) with GPL– Free except for commercial use

Xlib GDI Carbon

Unix/Linux MS Windows Mac OS XEmbedded

Linux

QT API

QT Application Source Code

Page 7: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 7/23

Before Start..

• Knowledge about C++– At first, you can use C– Recommend C seminar leaded by battery (

[email protected])

• Understanding of OOP• How to install

– By yourself..

Page 8: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 8/23

How to use

• QApplication– Necessary header file

• Widget in QT– Include [widget_name].h– Interface that provide control

• QObject– Basic class– Provide signal & slot

#include <qapplication.h>#include <qlabel.h>

Page 9: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 9/23

How to use

• Why qmake?– Just easy…

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

QApplication app (argc, argv);QLabel *label = new QLabel("Hello Qt!", 0);app.setMainWidget(label);label->show();return app.exec();

}

qmake -project

qmake hello.pro

Makefile

hello.pro

Page 10: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 10/23

How to use

• Signal & Slot

– Connect(), disconnect()

• Moc (Meta Object Compiler)– Make source file that C++ compiler can understand fr

om your well-defined file (generally from header file)

Page 11: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 11/23

How to use

• Header file

class FindDialog : public QDialog{ Q_OBJECT public: FindDialog(QWidget *parent=0, const char *name=0); signals: void findNext(const QString &str, bool caseSensitive); … private slots: void findClicked(); void enableFindButton(const QString &text); private: …};

Page 12: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 12/23

How to use

• Source file (cpp)#include "finddialog.h”…FindDialog::FindDialog(QWidget *parent, const char *name) : QDialog(parent, name) {… connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked()));…void FindDialog::findClicked(){ QString text=lineEdit->text(); bool caseSensitive = caseCheckBox->isOn(); if (backwardCheckBox->isOn()) emit findPrev(text,caseSensitive); else emit findNext(text,caseSensitive);}

Page 13: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 13/23

Qt Designer

• Powerful GUI layout and forms builder– Save time to make UI– Easy for connection

Page 14: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 14/23

Qt Designer

• How to make Connections• How to modify Source

• Right click on the widget

Page 15: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 15/23

Qt Designer

Page 16: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 16/23

Qt Designer

• Very useful!• Make layout, form and connection• Don’t program in Qt designer!• Just design and use vim

Page 17: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 17/23

Qt-embedded

• Use Qt for Embedded Programming• For mobile, PDA and embedded linux

QT Application Source Code

Binary file for X86 Binary file for Embedded Linux

Qt-embedded-x86 Qt-embedded

Virtual Frame Buffer Embedded Machine

redirection porting

Page 18: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 18/23

Qt-embedded

• qt-embedded-free– Qvfb, qt-embedded compiler

• QT Virtual Frame Buffer– Embedded machine use Frame buffer, not X– Test in host before porting application

qvfb –width 640 –height 480 –depth 32 &

Page 19: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 19/23

Qt-embedded

• Execution in qvfb

• Unexpected Error

– With sudo..

./demofile -qws

Semop unlock failure 부적절한 인수Semop lock failure 부적절한 인수

Page 20: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 20/23

Others from Qt

• Qtopia– an application platform and user interface for embedd

ed Linux

• Binding for other Language– Python, Ruby, Perl, etc.

• Qt Linguist, Qt Assistant, QSA, and so on.

Page 21: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 21/23

Further Work

• Qt study..?– More than 5 people who wanna learn more about Qt

• Qt Embedded Programming..?– Other members who have interest– Need more support

• More specific Qt seminar– Enough time, many attendances– But, 귀차니즘…

Page 22: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 22/23

Reference

• Trolltech– http://www.trolltech.com

• Qt 4 Open Source Edition download– http://www.trolltech.com/download/opensource.html

• Qt 4.1 Refernce Document– http://doc.trolltech.com/4.1/

• Qt Community site– http://www.qtcentre.org

Page 23: QT Intro. 김기형 (kkhsoft@sparcs.org)

Made and Designed by KKHSOFT. SPARCS 23/23

Thank you!

Any Question..?