출처 : http://doc.qt.io/qt-4.8/gettingstartedqt.html


Hello Notepad


코드.


#include <QApplication>

#include <QTextEdit>


int main (int argv, char **args)

{

QApplication app(argv, args);

QTextEdit textEdit;


textEdit.show();


return app.exec();

}



실행화면.



설명.


1. 헤더파일 생략.

#include <QApplication>

#include <QTextEdit>


2. 매인 함수 생략.

int main (int argv, char **args)

{



3. QApplication object.

QApplication app(argv, args);

 This object manages application-wide resources and is necessary to run any Qt program that has a GUI. It needs argv and args because Qt accepts a few command line arguments.


 - 위의 Object는 Application의 전체적인 리소스 관리와 모든 Qt 프로그램이 실행할때 필수적으로 사용.

 - 파라미터로 받는거 처리.


4. QTextEdit object.

QTextEdit textEdit;

A text edit is a visual element in the GUI. In Qt, we call such elements widgets. Examples of other widgets are scroll bars, labels, and radio buttons. A widget can also be a container for other widgets; a dialog or a main application window, for example.


- text edit은 GUI의 시각적인 요소.


5. TextEdit show.

textEdit.show();

Since widgets also function as containers (for instance a QMainWindow, which has toolbars, menus, a status bar, and a few other widgets), it is possible to show a single widget in its own window. Widgets are not visible by default; the function show() makes the widget visible.


- 윈도우에 위젯 표시.


6. Enter event loop.

return app.exec();

When a Qt application is running, events are generated and sent to the widgets of the application. Examples of events are mouse presses and key strokes. When you type text in the text edit widget, it receives key pressed events and responds by drawing the text typed.


 - 이벤트를 받아서 처리하는 것.


7. End.

}


8. Compile

qmake -project

qmake

make


Learn More


Widgets and Window Geometry

 - http://joomin.tistory.com/65


Events and event handling 




'Development > Qt' 카테고리의 다른 글

[Qt] Window and Dialog Widgets.  (0) 2015.11.06
[Qt] User name 확인하기  (0) 2015.09.14
[Qt] 창 닫기  (0) 2015.09.11
[Qt] Push button action 추가.  (0) 2015.09.11
[Qt] GUI design  (0) 2015.09.11