1. JDK 다운로드 및 설치
JDK(Java SE Developmemt Kit) 다운로드를 위해 여기를 클릭하여 스크롤을 조금 내리면 다음과 같이 화면에 나타납니다.

Windows x64 Installer를 다운로드합니다(JDK 최신 버전을 깔면 배포 파일 만드는 도중 에러가 나므로 17버전을 설치해야 합니다).
다운받은 파일을 실행하면 다음과 같이 화면에 나타납니다.

Next를 클릭하면 다음과 같이 화면이 바뀝니다.

Next를 클릭하면 다음과 같이 화면이 나타나며 설치가 됩니다.

압축풀기가가 완료되면 다음과 같이 화면에 나타납니다.

Close를 클릭하면 설치가 종료됩니다.
2. 안드로이드 QT 컴파일러 설치

QT를 설치한 폴더로 가 MaintenanceTool을 실행하면 다음과 같이 화면에 나타납니다.

QT 계정 정보를 넣고 다음을 클릭하면 다음과 같이 화면이 바뀝니다.

구성요소 추가 또는 제거를 선택하고 다음을 클릭한 후 QT 트리를 펼치면 다음과 같이 화면이 바뀝니다.

Android가 체크 되어 있지 않으면 체크를 하고 다음을 클릭하면 다음과 같이 화면이 바뀝니다(체크가 되어 있다면 설치된 것이므로 설치 하지 않아도 됩니다).

업데이트를 클릭하면 설치가 됩니다.
3. QT Creator 설정
QT Creator를 실행하여 Edit 메뉴의 부메뉴 Preferences를 실행하여 Devices탭을 선택하면 다음과 같은 대화상자가 나타납니다.

JDK location의 Browe...를 클릭하여 JDP폴더(여기서는 C:\Program Files\Java\jdk-22)를 선택합니다.

Set Up SDK 버튼을 클릭하면 다음과 같이 화면에 나타납니다.

Yes를 클릭하면 다음과 같이 화면에 나타납니다.

잠시후 다음과 같이 화면에 나타납니다.

OK를 클릭하면 다음과 같이 화면에 나타나 license 동의를 구합니다.

Yes를 선택하며 설치가 진행이 됩니다. 진행을 하며 다음과 같이 여러번 license 동의를 구하는데 모두 Yes를 선택합니다.

license 동의를 모두 수락하면 다음과 같이 화면에 나타나며 설치가 됩니다.

설치가 완료되면 다음과 같이 화면이 나타납니다.

OK를 클릭하면 Preferences화면이 다음과 같이 빨간색으로 에러났던 부분이 모두 정상으로 표시됩니다.

3. 안드로이드 Emulator 설치하기
스마트폰을 직접 연결하여 개발 및 디버깅을 할 수 있으나 Emulator를 설치하여 사용하는 것이 더 편리합니다.

Preferences 화면에서 SDK Manager를 클릭하여 면 다음과 같이 화면에 나타납니다.

Android 12.0 (S) 트리를 펼친 후 Goolge APIS Intel x86_64 Atom System Image를 체크하고 Apply를 클릭하면 다음과 같이 화면에 나타납니다.

Goolge APIS Intel x86_64 Atom System Image를 체크하고 Apply를 클릭하면 다음과 같이 화면에 나타납니다.

OK를 클릭하면 다음과 같이 화면에 나타나며 설치가 됩니다.

설치가 완료되면 다음과 같이 화면에 나타납니다.

QT Creator를 재가동 한 후 Preferences를 다시 띄워 Devices를 선택하면 다음과 같이 화면에 나타납니다.

Add를 클릭하면 다음과 같이 화면에 나타납니다.

Android Device를 선택(앞에서 QT Creator를 재가동 하지 않았으면 보이지 않습니다)하고 Start Wizard를 클릭하면 다음과 같이 화면에 나타납니다.

다음은 필요한 설정을 한 모양입니다.

OK를 클릭하면 Device에 AndroidEmulator가 추가됩니다.

AndroidEmulator를 선택하고 OK를 클릭하면 설정이 완료됩니다.
만약 설정 중 HAXM이 설치 되지 않아 에러가 나는 경우 여기를 참조하여 설치후 작업하면 됩니다.
4. 프로그램 작성 및 디버깅
프로그램은 QT08. 파일 및 인쇄에서 작성한 소스를 컴파일해 보도록 하겠습니다.
다음은 해당 소스를 QT Creator에서 연 모양입니다.

Projects를 선택하면 다음과 같이 화면에 나타납니다.

Android Qt 6.2.3 Clang x86_64 아래 Build를 마우스로 클릭하면 안드로이드용으로 컴파일 하도록 설정이 됩니다.
Edit를 선택하여 프로젝트에서 마우스 오른쪽 버튼을 누르면 다음과 같이 화면에 나타납니다.

Build를 클릭하면 잠시후 다음과 같은 에러가 발생합니다.

해당 에러를 마우스로 더블 클릭하면 다음과 같이 화면에 나타납니다.

vsprintf_s는 사실 vsprintf로 수정하면 문제 없이 동작합니다(PC에서는 vsprintf_s와 vsprintf가 모두 지원하고, 안드로이드에서는 vsprintf만 지원합니다). 여기서는 가끔 안드로이드용과 PC용 프로그램을 다르게 작성해야 하는 경우 하나의 소스로 관리할 수 있도록 하는 기법을 설명하도록 하겠습니다.
vsprintf_s(pData, str, vl); 를 아래와 같이 수정합니다.
#ifdef _ANDROID vsprintf(pData, str, vl); #else vsprintf_s(pData, str, vl); #endif |
vsprintf_s(pData, strFormat.GetData(), vl);를 아래와 같이 수정합니다.
#ifdef _ANDROID vsprintf(pData, strFormat.GetData(), vl); #else vsprintf_s(pData, strFormat.GetData(), vl); #endif |
#ifdef _ANDROID #else #endif 문에 의해 _ANDROID가 정의 되어있는 경우와 아닌경우 다르게 소스를 작성했습니다.
이제 _ANDROID를 정의하는 방법에 대해 설명하겠습니다.
GraphicEditor.pro를 더블클릭하면 다음과 같이 화면에 나타납니다.

가장 아래로 내려 다음과 같이 입력합니다.
unix:android: DEFINES += _ANDROID |
android일 경우 _ANDROID를 정의하도록 합니다.
다음은 입력한 모양입니다.

이제 F5를 누르면 컴파일이 되는 동안 에뮬레이터가 실행이 되고 다음과 같이 디버그 모드로 실행이 됩니다.

예제 프로그램
'QT' 카테고리의 다른 글
QT00. 목차 (0) | 2024.09.14 |
---|---|
QT11. Linux 개발환경 구축 (7) | 2024.09.14 |
QT09. DLL 만들기 및 배포하기 (0) | 2022.04.10 |
QT06. 스크롤 (0) | 2022.03.17 |
설치 파일 만들기 (0) | 2022.03.12 |