Update BarcodeEncoder to make use of Image Provider in order to display the image of the generated barcode to the QML viewe.

This commit is contained in:
favoritas37 2016-06-16 01:16:35 +03:00
parent 81b63588ae
commit 916903ed83
3 changed files with 4 additions and 1 deletions

View File

@ -6,7 +6,7 @@ DEPLOYMENTFOLDERS = folder_01
# Additional import path used to resolve QML modules in Creator's code model # Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH = QML_IMPORT_PATH =
CONFIG += gnu++11 #CONFIG += gnu++11
QMAKE_CXXFLAGS += -std=gnu++11 QMAKE_CXXFLAGS += -std=gnu++11
# The .cpp file which was generated for your project. Feel free to hack it. # The .cpp file which was generated for your project. Feel free to hack it.

View File

@ -9,6 +9,8 @@ int main(int argc, char *argv[])
QZXing::registerQMLTypes(); QZXing::registerQMLTypes();
QtQuick2ApplicationViewer viewer; QtQuick2ApplicationViewer viewer;
QZXing::registerQMLImageProvider(viewer);
viewer.setMainQmlFile(QStringLiteral("qml/BarcodeEncoder/main.qml")); viewer.setMainQmlFile(QStringLiteral("qml/BarcodeEncoder/main.qml"));
viewer.showExpanded(); viewer.showExpanded();

View File

@ -23,6 +23,7 @@ Rectangle {
onClicked: { onClicked: {
qzxing.encodeData(inputField.text) qzxing.encodeData(inputField.text)
inputField.text = ''; inputField.text = '';
resultImage.source = "image://QZXing/latestEncoded";
} }
} }