Qt Quick Controls - 연락처 목록

Qt Quick Controls 및 간단한 연락처 목록을 구현하는 C++ 클래스를 사용하는 QML 앱입니다.

연락처 목록 예제는 Qt Quick 디자이너와 호환되는 방식으로 C++ 백엔드를 통합하는 방법을 보여줍니다. UI의 선언적 부분에는 Qt Quick 디자이너에서 시각적으로 편집할 수 있는 .ui.qml 파일이 사용됩니다.

C++ 백엔드

연락처 목록 애플리케이션을 통해 사용자는 연락처를 추가, 편집, 제거할 수 있습니다. 실제 구현은 C++로 이루어지며 QAbstractListModel 로 노출됩니다.

ContactModel C++ 클래스는 네임스페이스에 등록되고 나중에 MainForm.ui.qml에서 가져와 인스턴스화됩니다. C++ 클래스를 QML 유형으로 등록하는 방법에 대한 자세한 내용은 C++에서 QML 유형 정의하기를 참조하세요.

#include <QtQml/qqml.h>
...
qmlRegisterType<ContactModel>("Backend", 1, 0, "ContactModel");
...

디자이너 지원

디자이너 하위 디렉터리에서 Qt Quick 디자이너의 ContactModel을 대체하는 플러그인을 만듭니다. 이 플러그인이 작동하려면 contactlist.pro에 다음 줄을 추가합니다.

QML_DESIGNER_IMPORT_PATH = $$PWD/designer

Qt Quick 디자이너는 ContactModel C++ 클래스를 인스턴스화할 수 없으므로 ListModel 을 사용하여 모형을 정의합니다. 이렇게 하면 모델을 사용하는 ListViewQt Quick 디자이너에서 무언가를 표시하도록 합니다.

예제 실행하기

에서 예제를 실행하려면 Qt Creator에서 Welcome 모드를 열고 Examples 에서 예제를 선택합니다. 자세한 내용은 예제 빌드 및 실행하기를 참조하세요.

예제 프로젝트 @ code.qt.io

© 2025 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.