Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Qt on Android : custom module not installed

[Solved] Qt on Android : custom module not installed

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 2.5k Views
  • 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.
  • F Offline
    F Offline
    franchouze
    wrote on last edited by
    #1

    Hello,
    I am very new to QML and I am developping an app using Qt 5.2.1 on CentOS 6.4
    When deploying my app on my android device I get the message : "could not load : assets :/qml/MyProject/MyPage.qml:5 module "ImageProcessor" is not installed

    [EDIT] this problem comes also when I compile in Desktop mode. My post may not be at the right part of the forum. [/EDIT]

    I already checked previous posts on this forum and I checked that :

    • my call to qmlRegisterType is before the definiton to the main qml file
    • my C++ object inherits from QObject

    I used http://kunalmaemo.blogspot.fr/2013/06/using-qml-camera-and-passing-image-to-c.html as my starting point.

    Here is the code :
    main.cpp
    @
    int main(int argc, char *argv[])
    {
    qmlRegisterType<ImageProcessor>("ImageProcessor",1,0,"ImageProcessor");

    QGuiApplication app(argc, argv);            
    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile&#40;QStringLiteral("qml/MyProject/main.qml"&#41;&#41;;
    viewer.showExpanded(&#41;;
    
    return app.exec&#40;&#41;;
    

    }@

    ImageProcessor.cpp
    @#include <QtQml/QQmlEngine>
    #include <QtQml/QQmlContext>
    #include <QtQuick/QQuickImageProvider>
    #include <QDebug>

    #include "ImageProcessor.h"

    ImageProcessor::ImageProcessor(QObject parent) :
    QObject(parent)
    {
    }
    void ImageProcessor::processImage(const QString & filename)
    {
    QUrl imageUrl(filename);
    QQmlEngine * engine = QQmlEngine::contextForObject(this)->engine();
    QQmlImageProviderBase * imageProviderBase = engine->imageProvider(imageUrl.host());
    QQuickImageProvider
    imageProvider = static_cast<QQuickImageProvider*>(imageProviderBase);
    QSize imageSize;
    QString imageId = imageUrl.path().remove(0,1);
    QImage image = imageProvider->requestImage(imageId,&imageSize,imageSize);
    if(!image.isNull()){

    }
    

    }@

    ImageProcessor.h
    @#include <QObject>

    class ImageProcessor : public QObject
    {
    Q_OBJECT

    public:
    explicit ImageProcessor(QObject *parent = 0);

    signals:

    public slots:
    Q_INVOKABLE void processImage(const QString & filename);

    };@

    MyPage.qml
    @
    import QtQuick 2.0
    import QtMultimedia 5.0
    import ImageProcessor 1.0

    Rectangle {
    anchors.fill: parent

    //shows live preview from camera
    VideoOutput {
        source: camera
        anchors.fill: parent
        focus : visible
    }
    
    //shows captured image
    Image {
        id: photoPreview
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
    }
    
    Camera {
        id: camera
        imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
        captureMode: Camera.CaptureStillImage
    
        exposure {
            exposureCompensation: -1.0
            exposureMode: Camera.ExposurePortrait
        }
    
        flash.mode: Camera.FlashRedEyeReduction
    
        imageCapture {
            onImageCaptured: {
                photoPreview.source = preview
                imageProcessor.processImage(preview);
            }
        }
    }
    
    MouseArea{
        anchors.fill: parent
        onClicked: {
            camera.imageCapture.capture();
        }
    }
    
    //image processor for further image processing
    

    ImageProcessor{
    id: imageProcessor
    }
    }@

    My .pro file:
    @# Add more folders to ship with the application, here
    folder_01.source = qml/MyProject
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    Additional import path used to resolve QML modules in Creator's code model

    QML_IMPORT_PATH =

    The .cpp file which was generated for your project. Feel free to hack it.

    SOURCES += main.cpp
    ImageProcessor.cpp

    Installation path

    target.path =

    Please do not modify the following two lines. Required for deployment.

    include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
    qtcAddDeployment()

    #allow to use the camera
    QT += multimedia
    QT += declarative

    HEADERS +=
    ImageProcessor.h
    @

    Could this be related to thje QML_IMPORT_PATH ? Any other idea about this ?
    Thanks for your help.
    François

    1 Reply Last reply
    0
    • F Offline
      F Offline
      franchouze
      wrote on last edited by
      #2

      Ok I finally found it :)

      The ImageProcessor class should inherits from QQuickItem and not Qobject.

      In the pro file remove
      QT += declarative
      and add
      QT += quick

      Hope that will help

      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