Installation and Deployment
2018.07.27 23:17

Qml 어플리케이션 정적 빌드

조회 수 7817 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

Qml리소스가 포함된 어플리케이션 정적 빌드의 경우 qmake는 qmlimportscanner 도구를 호출하여 응용 프로그램의 .qml 파일을 검색하고 Qml 연관된 각 정적 플러그인을 가져 오기위한 Q_IMPORT_PLUGIN() 호출을 포함하는 <target_name>_qml_plugin_import.cpp 파일을 생성한다.

 

예를 들어 아래 소스코드와같이  import 문을 사용하는 QtQuick 및 QtQuick.Window의 간단한 QML 응용 프로그램의 경우  

 

import QtQuick 2.5
import QtQuick.Window 2.1

Window {
  id: idRoot
  visible: true
  width: 640
  height: 480
  title: qsTr("Hello World")


  Rectangle{
    width: 300
    height: 300
    anchors.centerIn: parent
    color: "green"

    Text{
      text: idRoot.title
      font.pixelSize: 20
      color: "white"
      anchors.centerIn: parent
    }
  }
}

 

컴파일이 시작될때 다음 문이 생성된다.  

Q_IMPORT_PLUGIN(QtQuick2Plugin)
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)

 

Image.png

 

중요한 것은 QML 가져오기에 사용되는 리소스(플러그인)를 QML엔진에 제공해야 한다.  그렇지 않으면 아래와 같은 에러를 출력하며 응용프로그램이 실행되지 않는다.

 

QQmlApplicationEngine failed to load component

qrc:/main.qml:1 module "QtQuick" is not installed

qrc:/main.qml:2 module "QtQuick.Window" is not installed

 

이경우 가장 좋은 방법은 원본 위치의 파일을 응용 프로그램의 프로젝트 디렉터리로 복사하고 응용 프로그램 자체의 리소스와 함께 시스템에 추가하는 것이다.

플러그인이 추가 리소스(. qml,. js 또는 이미지 파일)를 사용하지 않더라도 최소한 해당 qmldir 파일에 액세스 할 수 있어야하며, QML  import 경로 아래에 있어야 한다.

 

예를 들어, Qt 리소스 콜렉션 파일 (.qrc)의 다음 항목은 qmldir 파일을 자원의 / prefix 아래에 배치한다.

 

Image.png

 

마지막으로 QML 엔진에 현재 리소스의 import 경로에 대해 알려야한다. 

다음 main() 구현은 main.qml을 로드하기 전에 "qrc :/" 에 대한  import  경로를 설정한다.

#include <QGuiApplication>
#include <QQmlApplicationEngine>

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

  QQmlApplicationEngine engine;
  engine.setImportPathList(QStringList(QStringLiteral("qrc:/")));
  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  if (engine.rootObjects().isEmpty())
    return -1;

  return app.exec();
}

 

참고:

 

 


  1. No Image notice

    Qt프로그래밍(QtQuick) Beginner를 위한 글 읽는 순서

    Date2019.01.05 CategoryQML and Qt Quick By운영자 Views131086
    read more
  2. QtWayland와 ivi-compositor

    Date2018.12.27 CategoryMobile and Embedded Bymakersweb Views8460
    Read More
  3. Qml과 C++로 구현하는 GUI어플리케이션

    Date2018.12.25 CategoryQML and Qt Quick Bymakersweb Views20401
    Read More
  4. No Image

    싱글터치 스크린 및 임베디드 리눅스 기반에서 Qt 터치입력

    Date2018.12.24 CategoryMobile and Embedded Bymakersweb Views7390
    Read More
  5. ShaderEffect QML Type 을 이용한 그래픽효과

    Date2018.12.09 CategoryQML and Qt Quick Bymakersweb Views8812
    Read More
  6. No Image

    Qml에서 커튼효과 구현 예제 - Shader Effects

    Date2018.12.05 CategoryQML and Qt Quick By운영자 Views6681
    Read More
  7. 안드로이드 Qt 프로그래밍

    Date2018.11.30 CategoryMobile and Embedded Bymakersweb Views15641
    Read More
  8. 리눅스에서 Qt4.8기반 어플리케이션의 한글입력

    Date2018.11.29 CategoryInstallation and Deployment Bymakersweb Views9472
    Read More
  9. QML에서 동적으로 텍스트 다국어 처리

    Date2018.11.04 CategoryQML and Qt Quick Bymakersweb Views9712
    Read More
  10. Qt Installer Framework - 패키징, 설치프로그램 제작

    Date2018.10.14 CategoryInstallation and Deployment Bymakersweb Views20748
    Read More
  11. Qt 응용프로그램 배포(windows)

    Date2018.10.10 CategoryGeneral and Desktop Bymakersweb Views17175
    Read More
  12. No Image

    소스코드에서 환경변수 가져오기와 설정하기

    Date2018.10.08 CategoryGeneral and Desktop Bymakersweb Views7973
    Read More
  13. 표를 만들고 PDF문서로 출력하기

    Date2018.09.30 CategoryGeneral and Desktop Bymakersweb Views6213
    Read More
  14. Qml에서 키보드 입력 이벤트 핸들링

    Date2018.08.09 CategoryQML and Qt Quick Bymakersweb Views10565
    Read More
  15. Qml 어플리케이션 정적 빌드

    Date2018.07.27 CategoryInstallation and Deployment Bymakersweb Views7817
    Read More
  16. No Image

    Qt Bluetooth 관련 기능 확인 사항

    Date2018.07.10 CategoryInstallation and Deployment Bymakersweb Views6224
    Read More
  17. No Image

    Qml 및 C++개발시 유용한 팁

    Date2018.04.06 CategoryQML and Qt Quick Bymakersweb Views12974
    Read More
  18. No Image

    Qt Version확인 방법

    Date2018.03.29 CategoryGeneral and Desktop Bymakersweb Views9357
    Read More
  19. 초보자를 위한 첫번째 프로젝트 - QML로 만드는 Hello World

    Date2018.03.16 CategoryGeneral and Desktop Bymakersweb Views25281
    Read More
  20. Windows에서 라즈베리파이3 Qt 어플리케이션 개발 및 원격 실행

    Date2018.02.23 CategoryInstallation and Deployment Bymakersweb Views11219
    Read More
  21. Windows에서 라즈베리파이3용 Qt5.10.0 크로스컴파일

    Date2018.02.23 CategoryMobile and Embedded Bymakersweb Views19103
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 Next
/ 9