Open FRAYOURSELF opened 1 year ago
Hi @FRAYOURSELF,
the library comes with a sample app which is used to showcase the features of the library. To try the sample app, open the 'pdf-viewer.pro' file with Qt creator.
To start from scratch, you need to create a qt quick project first:
Then follow those steps (as stated in the section of the README):
QML_IMPORT_PATH += $$PWD/libs/qt-pdf-viewer-library/
QML_DESIGNER_IMPORT_PATH += $$PWD/libs/qt-pdf-viewer-library/
include($$PWD/libs/qt-pdf-viewer-library/qtpdfviewer.pri)
#include "it/ltdev/qt/cpp/components/qtpdfviewerinitializer.h"
int main(int argc, char *argv[])
{
...
// Initialize QtPdfViewer library
// To make the pdf module to function correctly across all platforms,
// it is necessary to call QtPdfViewerInitializer::initialize()
// before in Qt>= 5.15.0, or after in Qt<5.15.0, creating
// the QGuiApplication instance
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
LTDev::QtPdfViewerInitializer::initialize();
QGuiApplication app(argc, argv);
#else
QGuiApplication app(argc, argv);
LTDev::QtPdfViewerInitializer::initialize();
#endif
// Delete QtPdfViewer instance on app close
QObject::connect(&app, &QGuiApplication::aboutToQuit, LTDev::QtPdfViewerInitializer::getInstance(), LTDev::QtPdfViewerInitializer::deleteInstance);
QQmlApplicationEngine engine;
// Needed to import the custom module
engine.addImportPath("qrc:/");
engine.addImportPath(":/");
...
}
import it.ltdev.qt.qml.components 1.0
, and use the provided PdfView
class.import it.ltdev.qt.qml.components 1.0 as LTDev
ApplicationWindow {
...
LTDev.PdfView {
id: pdfView
anchors.fill: parent
onViewerLoaded: {
// Load pdf only when viewer is ready
pdfView.load("path/to/my/document.pdf")
}
onPdfLoaded: {
// Pdf has been correctly loaded
}
onError: {
// Some error occurred
console.error("Error: ", message)
}
}
}
Anyway, for more info, give a look to the sources of the sample app :D
On trying to build the project why I am getting this
For the qt quick application where is the .pro file??
How to set it up step-by-step. I am new to qt so stuck at various portions. Help me please.![qt_ss](https://user-images.githubusercontent.com/87349904/229922355-8d45a4a7-9ce6-465e-9e7a-02990e3e1a72.png)