Using C++ Library in QML



  • Hi All,

    I want to use QZXing in my QML project for barcode scanning. Anyone have any idea how to use that. Thanx in advance.



  • Read the documentation of the "QZXing at Nokia Developer":https://projects.developer.nokia.com/QZXing



  • I am following this link https://projects.developer.nokia.com/QZXing/wiki for using QZXing in qml. But i am not able to implement it successfully. Anyone have any idea how to do that.


  • Moderators

    A bit more info, would be nice. Like where exactly are you failing, what is the error reported, etc.



  • @ Sierdzio thnx for the rply. I am not able to incliding the QZXing.h file in my main C++ file. i had downloaded QZXing liberary from here https://github.com/zxing/zxing. And try to implement it according to this link https://projects.developer.nokia.com/QZXing/wiki , but i am unable to include QZXing.h .


  • Moderators

    Mate, but what is the error message? Is there any? Also, what code (exactly) have you added to your .pro file? What platform are you targeting?

    It's hard to help when I have to guess things, you know.



  • Actually i am working on QT Quick. And using Qt Quick 4.7 . And i had added that library in .pro file. Below is the code snip set of .pro file.

    Add more folders to ship with the application, here

    folder_01.source = qml/QMLBarcodeScanner
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

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

    QML_IMPORT_PATH =

    symbian:TARGET.UID3 = 0xE35E8B99

    Smart Installer package's UID

    This UID is from the protected range and therefore the package will

    fail to install if self-signed. By default qmake uses the unprotected

    range value if unprotected UID is defined for the application and

    0x2002CCCF value if protected UID is given to the application

    #symbian:DEPLOYMENT.installer_header = 0x2002CCCF

    Allow network access on Symbian

    #symbian:TARGET.CAPABILITY += NetworkServices

    If your application uses the Qt Mobility libraries, uncomment the following

    lines and add the respective components to the MOBILITY variable.

    CONFIG += mobility

    MOBILITY +=

    Speed up launching on MeeGo/Harmattan when using applauncherd daemon

    CONFIG += qdeclarative-boostable

    Add dependency to Symbian components

    CONFIG += qt-components

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

    SOURCES += main.cpp

    symbian{
    LIBS += -lqzxing
    customrules.pkg_prerules =
    ";QZXing"
    "@"$$(EPOCROOT)Epoc32/InstallToDevice/QZXing_selfsigned.sis",(0xE618743C)"
    " "
    DEPLOYMENT += customrules
    }

    win32{
    LIBS += -LC:/QtSDKProjects/QMLBarcodeScanner/Qt_4.7.4_Desktop_Mingw
    -lQZXing
    }

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

    include(qmlapplicationviewer/qmlapplicationviewer.pri)
    qtcAddDeployment()

    Now i think u will able to help me.


  • Moderators

    Thanks, that is much better.

    Seems you forgot to include this line:
    @
    INCLUDEPATH += "absolute path of the folder where the files where placed"
    @

    This is probably why you cannot include the file - without include path set, compiler does not "see" the header of qzxing lib.



  • Now library is added in project but it is given this error on compile time :

    *d:/qt/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lQZXing
    collect2: ld returned 1 exit status
    mingw32-make.exe[1]: *** [debug\QMLBarcodeScanner.exe] Error 1
    mingw32-make.exe: *** [debug] Error 2
    14:38:25: The process "D:\QT\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project QMLBarcodeScanner (target: Qt Simulator)
    When executing build step 'Make' *


  • Moderators

    Is the library compiled?

    Also, the wiki seems to differ between -lQZXing and -lQZXing_selfsigned - maybe you are linking against wrong library?



  • I download the library from here: https://github.com/zxing/zxing and i think this is compiled. And this is my .pro file code :

    symbian{
    LIBS += -lqzxing
    customrules.pkg_prerules =
    ";QZXing"
    "@"$$(EPOCROOT)Epoc32/InstallToDevice/QZXing_selfsigned.sis",(0xE618743C)"
    " "
    DEPLOYMENT += customrules
    }

    win32{
    LIBS += -LC:/QtSDKProjects/QMLBarcodeScanner/Qt_4.7.4_Desktop_Mingw
    -lQZXing
    INCLUDEPATH += "D:\QT\Symbian\SDKs\Symbian3Qt474\epoc32\include"
    }

    and i think u will able to solve it out this time.


  • Moderators

    Whoa! In both INCLUDEPATH and LIBS, you point to Qt installation! Those have to point to files in your QZXing installation (headers/ compiled dlls respectively), so that compiler (and qmake) knows where to fine both the qzxing.h and qzxing.so (or .dll, or .a, depending on platform and a few other things). If your project needs both includes, you can include more paths just like in "SOURCES" calls ("" to break the line, then add another entry)



  • @ Sierdzio, Thnx for your precious time...i am able to run my project on simulator but not able to run it on my nokia symbian bele (NOKIA 603). It is giving error:

    Error while building project QMLBarcodeScanner (target: Symbian Device) When executing build step 'qmake'


  • Moderators

    Good to know we made some progress, but I am afraid my help will have stop here - I have no experience in developing on Symbian.

    The only thing that comes to my mind is that - maybe - you have to copy the library to the symbian device, too. But that is just a guess, I really don't know anything about Symbian.



  • Hi all,

    I am able to access QZXing for the simulator . But when it comes for Symbian device it is not accessible
    I think there is a problem from the symbian target in my .pro file. Below is the code snip shot of my .pro file for symbian is:

    _ LIBS += -lqzxing
    customrules.pkg_prerules =
    ";QZXing"
    "@"$$(EPOCROOT)Epoc32/InstallToDevice/QZXing_selfsigned.sis",(0xE618743C)"
    " "
    DEPLOYMENT += customrules_

    This declaration is same as given here : https://projects.developer.nokia.com/QZXing/wiki

    But in my case the the library is not included.

    Thnx for any help in advance.



  • Your first problem is that your project folder is in a different disk drive compared to the disk drive that the Symbian SDK is installed. Symbian toolchain requires that the projects built must be in the same drive as the Symbian SDK so first fix that.

    Moreover the following code is unnecessary when building for Symbian since that path is already included. That is why the project's wiki says to copy the binaries in the epoc32 folder.
    @
    INCLUDEPATH += “D:\QT\Symbian\SDKs\Symbian3Qt474\epoc32\include”
    @

    One note here is that i am a bit curious on how, as you say, it works for Qt Simulator. I haven't supported it event though it can be done with some modifications.

    Finally, if you are getting error when qmake is executed this means that there is a syntax error in your .pro file. If you are still experiencing the same error post the .pro but included in the code tags (place a "@" at the beginning and end of the code ).



  • This thread is continued "here":http://qt-project.org/forums/viewthread/17435/.


Log in to reply
 

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