Book Image

QT5 Blueprints

By : Symeon Huang
Book Image

QT5 Blueprints

By: Symeon Huang

Overview of this book

Table of Contents (17 chapters)
Qt 5 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a C++ plugin for QML applications


It's not too difficult to write a plugin for Qt/C++ applications, whereas it's somewhat more complex to create a plugin for the QML applications. The idea is the same, and here we will use a very basic example to demonstrate this topic. Basically, this application will encode the text input as Base64 and display it. The Base64 encoding part is implemented in the C++ plugin.

This time, we're going to create the plugin project first, and then complete the QML part. Creating a plugin project for a QML application shares the same procedure. Navigate to Libraries | C++ Library, and then select Qt Plugin with the name as Base64Plugin. Its project file, Base64Plugin.pro, is pasted here:

QT       += core qml

TARGET = qmlbase64Plugin
TEMPLATE = lib
CONFIG += plugin

DESTDIR = ../imports/Base64

SOURCES += base64.cpp \
           base64plugin.cpp

HEADERS += base64.h \
           base64plugin.h

OTHER_FILES += \
           qmldir

We set DESTDIR to ../imports...