Unsolved QML show PDF file
-
Let me add that for QML you'd need to wrap rendering into C++ backend, I am not aware of any direct method to use with QML (but then again, I am no expert in QML).
-
You can use poppler as I show in this post: https://stackoverflow.com/a/52844509/6622587
-
@artwaw: Thank you. I will try Poppler.
-
This post is deleted! -
@eyllanesc: Ok. Thank you for the example. I compiled and installed the plugin. But why is it "import org.docviewer.poppler 1.0"?
This gives me the error "module "org.docviewer.poppler" is not installed".
Maybe I should mention that I am cross compiling on Ubuntu my application for raspberry pi. -
@Melle_87 said in QML show PDF file:
But why is it "import org.docviewer.poppler 1.0"?
Well, because you need to import Poppler stuff if you want to use it.
"I compiled and installed the plugin" - did you cross-compiled it for your device or host machine? -
@jsulm: At the moment I am a little bit confused.
I compiled and installed it directly on my raspberry. -
@Melle_87 said in QML show PDF file:
I compiled and installed it directly on my raspberry
It needs to be in your sysroot. Did you resync your sysroot after installing on RPi?
-
@jsulm: Ah okay. Of course, I have to resync my sysroot. I resynced the folders /usr/local/include, /usr/local/lib and /usr/lib/arm-linux-gnueabihf/qt5 from raspberry to host.
Then I added this to my qmldir file:
module org.docviewer.poppler PDFView 1.0 PDFView.qml plugin popplerPlugin typeinfo popplerPlugin.qmltypes
But now I get the error message:
plugin "popplerPlugin" not found
What is the reason for this error message?
-
@Melle_87 I'm not a QML expert.
Not sure you have to change qmldir.
When you installed Poppler on RPi - where was it installed? -
@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?