develtar / qt-pdf-viewer-library

The qt-pdf-viewer-library is a qml wrapper of pdf.js library which allows you to render PDF files in a WebView. This library also works on Android devices, and it uses WebSocketServer, WebSocketTransport and WebChannel to exchange data between qml and the browser environment.
Apache License 2.0
41 stars 9 forks source link

module "it.ltdev.qt.qml.components" is not installed #2

Closed ic005k closed 1 year ago

ic005k commented 1 year ago

First of all thank you for doing such a great job.

When I load "PdfPage.qml" into a quickWidget, it always reports the following error:

qrc:/sample/PdfPage.qml:10:1: module "it.ltdev.qt.qml.components" is not installed The import it.ltdev.qt.qml.com 1.0 as LTDev ponents

I tried to install the module using the following method: engine-> AddImportPath: ("/"); or Qputenv: (" QML2_IMPORT_PATH ", "/"); It still doesn't work.

However, when I used QQmlApplicationEngine to load "PdfPage.qml", everything worked perfectly.

Do you have any suggestions, please? Thank you very much!

Also, can simplify the use of this module ponents "it.ltdev.qt.qml.com"? I found it to have a lot of hierarchical directories, which was a little confusing.

Thanks again.

ic005k commented 1 year ago

Or, can you write a demo using QQuickWidget? Hard work!

ic005k commented 1 year ago

To solve the problem, just add this code:

ui->quickWidget->engine()->addImportPath(":/");

Thanks again, perfect.

develtar commented 1 year ago

Thank you @ic005k, i'm glad you solved the problem!