Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Create QML Plugin (type not created)
Forum Updated to NodeBB v4.3 + New Features

Create QML Plugin (type not created)

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lolopolosko
    wrote on last edited by
    #1

    Hi!
    I created plugin using Poppler lib, but it does not work

    pro:
    @TEMPLATE = lib
    CONFIG += qt plugin
    QT += declarative

    LIBS += -L"/home/ruslan/Doc/Qt/Project/qmlPDf/libs" -lpoppler-qt4
    INCLUDEPATH += src/

    HEADERS +=
    qmlpdf.h
    qmlpdfplugin.h

    SOURCES +=
    qmlpdf.cpp
    qmlpdfplugin.cpp@

    plugin.h:
    @#ifndef QMLPDFPLUGIN_H
    #define QMLPDFPLUGIN_H

    #include <QDeclarativeExtensionPlugin>

    class qmlPDFPlugin : public QDeclarativeExtensionPlugin
    {
    Q_OBJECT
    public:
    void registerTypes(const char *uri);
    };

    #endif // QMLPDFPLUGIN_H
    @

    plugin.cpp:
    @#include "qmlpdfplugin.h"
    #include "qmlpdf.h"

    #include <QtDeclarative>

    void qmlPDFPlugin::registerTypes(const char *uri){
    qmlRegisterType<qmlPDF>(uri,1,0,"PDFView");
    }

    Q_EXPORT_PLUGIN2(qmlpdfplugin,qmlPDFPlugin);
    @

    DeclarItem.cpp:
    @#include "qmlpdf.h"
    #include "poppler-qt4.h"

    #include <QApplication>
    #include <QDesktopWidget>
    #include <QPainter>
    #include <QFile>
    #include <QDebug>

    qmlPDF::qmlPDF(QDeclarativeItem *parent) :
    QDeclarativeItem(parent)
    {
    docPDF = Poppler::Document::load("/home/ruslan/Doc/Qt/Project/PDFViewer/jni.pdf");
    setFlag(ItemHasNoContents,false);
    }
    @

    If I delete line @docPDF = Poppler::Document::load("/home/ruslan/Doc/Qt/Project/PDFViewer/jni.pdf"); @
    my plugin is good work, but another @Project/qmlPDf/App.qml:8:5: PDFView is not a type
    PDFView {
    ^ @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lolopolosko
      wrote on last edited by
      #2

      "Source code":http://zoki.org.ua/example.tar.gz

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lolopolosko
        wrote on last edited by
        #3

        Please! Help me!

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tolszak
          wrote on last edited by
          #4

          I think you missed to add qmlPDF/libs directory to your LD_LIBRARY_PATH so plugin could not find poppler library, Just copy plotter library to place where your executable is. BTW (Why do you declare all member variables, used as property value storage, public? Shouldn't they be private or protected?)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lolopolosko
            wrote on last edited by
            #5

            bq. I think you missed to add qmlPDF/libs directory to your LD_LIBRARY_PATH so plugin could not find poppler library

            I added poppler library in LIBS variable
            @LIBS += -L"libs-path" -lpoppler-qt4@

            bq. Why do you declare all member variables, used as property value storage, public? Shouldn’t they be private or protected?

            Qt Quick / QML works with the meta-object system and member variables are declared in the class as public does not see

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tolszak
              wrote on last edited by
              #6

              But it's in build time.
              When your run application (for exmaple qmlviewer) you need to set this path in LD_LIBRARY_PATH or copy this poppler library to place where qmlviewer is or other place where libraries are searched.

              @
              LIBS+= -L....
              @
              works only in build time.
              Please test with:
              LD_LIBRARY_PATH="/home/ruslan/Doc/Qt/Project/qmlPDf/libs"

              Additionally your App.qml files lacks of import.
              If your plugin binary is in the same place where App.qml is the you should add:
              @
              "import qmlPDFPlugin 1.0"
              @

              Could you please read whole documentation regarding:
              http://qt-project.org/doc/qt-4.8/declarative-tutorials-extending-chapter6-plugins.html

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lolopolosko
                wrote on last edited by
                #7

                Sorry, but this not work :(

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lolopolosko
                  wrote on last edited by
                  #8

                  Ok.. this is works!
                  I am build this project on Windows
                  Copies libs (poppler, zlib, openjpeg, freetype) in %QTDIR%\bin

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved