2015. 3. 19. 00:09

QCoreApplication 소개

출처 : http://doc.qt.io/qt-4.8/qcoreapplication.html#details

Detailed Description

자세한 설명

The QCoreApplication class provides an event loop for console Qt applications.

QCoreApplication 클래스는 콘솔 QT 응용프로그램들의 이벤트 루프를 제공합니다.

This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see QApplication.

이 클래스는 비-GUI 응용프로그램들에서 그들의 이벤트 루프를 제공하는데 사용됩니다. 정확히 하나의 QCoreApplication 객체만 있어야 합니다. GUI 응용프로그램들에 대해서는 QApplication 을 보시기 바랍니다.

QCoreApplication contains the main event loop, where all events from the operating system (e.g., timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.

QCoreApplication 은 운영체제가 전달하는 모든 이벤트 (예. 타이머, 네트워크 이벤트) 들과 다른 소스(이벤트)들이 처리되고 전달하는 메인 이벤트 루프를 포함하고 잇습니다. 그것은 또한 응용프로그램의 초기화와 마무리과정 그리고 시스템-범위와 응용프로그램-범위 설정들을 다루고 있습니다.

The Event Loop and Event Handling

이벤트 루프와 이벤트 핸들링 (처리)

The event loop is started with a call to exec(). Long running operations can call processEvents() to keep the application responsive.

이벤트 루프는 exec() 함수를 호출하는 것으로 시작합니다. 긴 실행 동작들은 응용 프로그램 응답성을 유지하기 위해 processEvent() 을 사용합니다.

In general, we recommend that you create a QCoreApplication or a QApplication object in your main() function as early as possible. exec() will not return until the event loop exits; e.g., when quit() is called.

일반적으로, 저희는 QCoreApplication 또는 QApplication 객체를 main() 함수에 되도록이면 빨리 실행되는 것을 추천합니다. exec() 는 이벤트 루프가 끝나기 전(예. quit() 가 불려질 때)까지 값을 되돌리지 않을 것입니다.

Several static convenience functions are also provided. The QCoreApplication object is available from instance(). Events can be sent or posted using sendEvent(), postEvent(), and sendPostedEvents(). Pending events can be removed with removePostedEvents() or flushed with flush().

몇몇 정적 편의 함수들 또한 제공됩니다. QCoreApplication 객체는 instance() 함수가 제공됩니다. 이벤트들은 sendEvent(), postEvent(), sendPostedEvents() 를 통해 전달되거나, 배치시킬 수 있습니다. 처리 대기중인 이벤트들은 removePostedEvents() 통해 제거하거나 또는 flush() 를 사용하여 비울 수 있습니다.

The class provides a quit() slot and an aboutToQuit() signal.

이 클래스는 quit() 슬롯과 aboutToQuit() 시그널을 제공합니다.

Application and Library Paths

응용프로그램과 라이브러리 경로

An application has an applicationDirPath() and an applicationFilePath(). Library paths (see QLibrary) can be retrieved with libraryPaths() and manipulated by setLibraryPaths(),addLibraryPath(), and removeLibraryPath().

응용프로그램은 applicationDirPath() 와 applicationFilePath() 를 가지고 있습니다. 라이브러리 경로 (QLibrary 참조) 는 libraryPaths() 를 사용하여 값을 얻을 수 있으며, setLibraryPaths(), addLibraryPath() 그리고 removeLibraryPath() 를 사용해서 수정이 가능합니다.

Internationalization and Translations

다국어와 번역

Translation files can be added or removed using installTranslator() and removeTranslator(). Application strings can be translated using translate(). The QObject::tr() and QObject::trUtf8() functions are implemented in terms of translate().

다국어용 변환 파일들은 installTranslator() 와 removeTranslator() 를 사용하여 추가 또는 제거가 가능합니다. 응용프로그램 문자열은 translate() 를 사용하여 변환이 가능합니다. QObject::tr() 과 QObject::trUtf8() 함수들이 translate() 을 사용하여 구현됩니다.

Accessing Command Line Arguments

명령줄 입력 인자 접근

The command line arguments which are passed to QCoreApplication's constructor should be accessed using the arguments() function. Note that some arguments supplied by the user may have been processed and removed by QCoreApplication.

QCoreApplication 의 생성자를 통해 전달 받는 명령줄 인자 (커맨드 라인 아규먼트) 들은 arguments() 함수를 통해 접근이 되어야 합니다. 사용자가 제공하는 몇몇 인자들은 QCoreApplication 에 의해 처리되고 제거 되어도 됩니다.

In cases where command line arguments need to be obtained using the argv() function, you must convert them from the local string encoding using QString::fromLocal8Bit().

argv() 함수를 통해서 명령줄 인자를 접근하는 경우, 사용자는 QString::fromLocal8Bit() 를 사용해서 로컬 문자열 인코딩을 변환해야 합니다.

Locale Settings

로케일 (언어) 설정

On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.

유닉스/리눅스 Qt 는 기본으로 시스템 로케일 설정들을 사용하게 구성되어 있습니다. 예를들어, 서로 다른 로케일간 동작이 다를 수 있는 부동소숫점과 문자열간 자료형 교체를 할때와 같이, 기본 설정은 POSIX 함수들과 충돌이 발생할 수 있습니다. 이 문제를 우회하기 위해, POSIX 함수 setlocale(LC_NUMERIC, "C") 를 QApplication 또는 QCoreApplication 이 초기화 된 이후 곧바로, 숫자 형식을 "C"-로케일 방식으로 초기화 하여 해결합니다.

See Also

같이보기

QApplicationQAbstractEventDispatcherQEventLoopSemaphores Example, and Wait Conditions Example.

QApplication, QAbstractEventDispatcher, QEventLoop, 세마포어 예제, 그리고 대기(기다림) 조건 예제

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.