Unsolved QML show PDF file
-
@jsulm: I think on raspi it was installed in /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Because in this folder I find popplerPlugin.qmltypes.
-
@Melle_87 said in QML show PDF file:
think on raspi it was installed in /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Because in this folder I find popplerPlugin.qmltypes.
You can follow the import process when setting environment variable
QML_IMPORT_TRACE
.
As written in documentation, QML import path is:Additional import paths can be added through QQmlEngine::addImportPath() or the QML2_IMPORT_PATH environment variable. When running the qmlscene tool, you can also use the -I option to add an import path.
Take a look here ==> https://doc.qt.io/qt-5/qtqml-syntax-imports.html#qml-import-path
-
@Melle_87 Does it work if you do not change qmldir?
-
@KroMignon: Thank you. So it is possible to set this QML2_IMPORT_PATH variable in Qt Creator in the Run Environment? I set this variable to /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Is this correct?
-
@jsulm: If I don't change the qmldir file I get "module "org.docviewer.poppler" is not installed".
-
@Melle_87 said in QML show PDF file:
So it is possible to set this QML2_IMPORT_PATH variable in Qt Creator in the Run Environment?
Yes, I think so. But I would suggest you first to try out
QML_IMPORT_TRACE
to be aware why your plugin in not loaded.
Perhaps there are missing libs?
==> https://doc.qt.io/qt-5/qtquick-debugging.html#debugging-module-imports -
@KroMignon: Thank for alle the tipps. I leave my qmldir file as it is and only set QML2_IMPORT_PATH = /usr/lib/arm-linux-gnueabihf/qt5/qml. Now the everything seems to be loaded correctly.
But now I have a new problem. On start up I get a "Segmentation fault".
I think the problem is that I compiled poppler with qmake of Qt 5.11.3. But actually I use Qt5.12.4. I have both Qt versions on the raspi. How can I explicitly use the qmake of Qt5.12.4 for compiling poppler? -
@Melle_87 said in QML show PDF file:
How can I explicitly use the qmake of Qt5.12.4 for compiling poppler?
By calling the qmake from the Qt version you want to use (use absolute path to qmake).
-
@jsulm: Hmmm... Okay. Unfortunately in Qt5.12.4 folder there is no qmake available ...
-
@Melle_87 said in QML show PDF file:
Qt5.12.4 folder there is no qmake available
Then this is not a valid Qt installation.
How did you install it? -
@jsulm: It was not me who installed the Qt version ... So I have to ask. But is there a way to get the qmake of this version?
Or maybe it would be easier to cross compile Poppler? -
@Melle_87 said in QML show PDF file:
Or maybe it would be easier to cross compile Poppler?
Cross compiling is more complex than building directly on the device. But you need to make sure you use same Qt version on device and host machine if you want to cross compile your app later.
"But is there a way to get the qmake of this version?" - sure. If it was installed using apt then install the qt dev packages, which exactly depends on the distribution.
-
Another quick and easy way to render a pdf with QML is to use a WebView together with pdfjs lib :
WebView{ url:"file:///%path_to_pdfjs%/web/viewer.html?file=file://%PathToFile%.pdf" }
You can find a working example in Swag projet : https://github.com/a-team-fr/swag/blob/master/Swag/PDFElement.qml
-
@Charby: Okay, thank you. I will have a look at it.
-
@jsulm: Ok. Now I am sure that I am using the same Qt libs on host an Raspi. Poppler was built with the same. But now I get a SEG FAULT on start up when I set the variable QML2_IMPORT_PATH = /usr/lib/arm-linux-gnueabihf/qt5/qml in run environment.
What could be the reason for that error? -
@Melle_87 said in QML show PDF file:
What could be the reason for that error?
Don't know. Run it through debugger.