To import pulgin in qml(Qt 4.7.4)



  • (opencv-camera-capture-with-qml) I am using this plugin from the below link

    http://f24h.altervista.org/blog/opencv-camera-capture-with-qml/

    Here is the steps what I followed
    @
    step 1

    Under Qt Quick Project->Qt Quick Ui

    Name : main
    Create in: /home/bts-007/QtSDK/work/

    step 2

    Extracted the(plugin) tar file with in the folder main

    step 3

    edited main.qml from the use case

    import opencv.components 1.0

    CvCamView {
        id: camView
        width: 800
        height: 600
        camera: 0
        cameraState: CvCamView.ActiveState //unneeded because this is the default state
        resolution: CvCamResolution {
                        width: 800
                        height: 600
                    }
        onNewFrame: {
            console.log("new frame recived");
            consumer.detectSomething(iplWidth, iplHeight, iplData);
        }
    
    }
    

    step 4
    changed main.qmlproject

    import QmlProject 1.1

    Project {
    mainFile: "main.qml"

    /* Include .qml, .js, and image files from current directory and subdirectories */
    QmlFiles {
        directory: "."
    }
    JavaScriptFiles {
        directory: "."
    }
    ImageFiles {
        directory: "."
    }
    /* List of plugin directories passed to QML runtime */
    importPaths: [ "." ]  // this is the change what I made(set to current path)
    

    }

    step 5
    run the program.
    @

    cvcamview_plugin.cpp

    @
    #include "cvcamview_plugin.h"
    #include "cvcamview.h"
    #include "cvcamresolution.h"
    #include "cvhaardetector.h"

    #include <QApplication>
    #include <QtDeclarative/qdeclarative.h>

    void CvCamViewPlugin::registerTypes(const char *uri)
    {
    // @uri opencv.components
    qmlRegisterType<CvCamResolution>(uri, 1, 0, "CvCamResolution");
    qmlRegisterType<CvCamView>(uri, 1, 0, "CvCamView");
    qmlRegisterType<CvHaarDetector>(uri, 1, 0, "CvHaarDetector");

    }

    Q_EXPORT_PLUGIN2(CvCamView, CvCamViewPlugin)
    @

    uri - opencv.components

    I am getting an error message module "opencv.components" is not installed
    import opencv.components 1.0 .

    I can access the properties but I don't know why it is showing the error message



  • What you probably need is this little piece of code:

    http://qt-project.org/doc/qt-5.0/qtqml/qqmlengine.html#addImportPath

    You need to do this in the main.cpp file. Or where ever you have access to the engine/viewer. Should work in 4.7.4 as well, I think. ;)

    For more information:
    http://qt-project.org/doc/qt-5.0/qtqml/qtqml-syntax-imports.html#qml-import-path

    http://qt-project.org/doc/qt-5.0/qtqml/qtqml-modules-identifiedmodules.html


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.