Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to import c++ qml plugin to python project?
Forum Updated to NodeBB v4.3 + New Features

How to import c++ qml plugin to python project?

Scheduled Pinned Locked Moved Unsolved Qt for Python
8 Posts 2 Posters 615 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.
  • K Offline
    K Offline
    Kamichanw
    wrote on last edited by
    #1

    I've written a c++/qml plugin and now I want to integrate it to my python project. However, even I set correct .dll path for QPluginLoader, the errorString()` still shows:

    The plugin 'C:/Users/ASUS/Documents/Qt Project/cv-tools/3rdparty/KmcUI/bin/KmcUI/KmcUI.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)
    

    What's more, all .qrc references in the library qml file seem to be invalid, so files referenced in qrc format cannot be used. How to solve my problems?

    JonBJ 1 Reply Last reply
    0
    • K Kamichanw

      I've written a c++/qml plugin and now I want to integrate it to my python project. However, even I set correct .dll path for QPluginLoader, the errorString()` still shows:

      The plugin 'C:/Users/ASUS/Documents/Qt Project/cv-tools/3rdparty/KmcUI/bin/KmcUI/KmcUI.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)
      

      What's more, all .qrc references in the library qml file seem to be invalid, so files referenced in qrc format cannot be used. How to solve my problems?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Kamichanw said in How to import c++ qml plugin to python project?:

      uses incompatible Qt library. (Cannot mix debug and release libraries.)

      So between this third-party library and your own code (or whatever the Python uses from Qt libraries) is one compiled for debug and the other for release?

      K 1 Reply Last reply
      0
      • JonBJ JonB

        @Kamichanw said in How to import c++ qml plugin to python project?:

        uses incompatible Qt library. (Cannot mix debug and release libraries.)

        So between this third-party library and your own code (or whatever the Python uses from Qt libraries) is one compiled for debug and the other for release?

        K Offline
        K Offline
        Kamichanw
        wrote on last edited by
        #3

        @JonB No. Actually, I just used debug mode to complie my library and load it in python project. In addition, I also compiled a release version, but it could not be loaded.

        JonBJ 1 Reply Last reply
        0
        • K Kamichanw

          @JonB No. Actually, I just used debug mode to complie my library and load it in python project. In addition, I also compiled a release version, but it could not be loaded.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Kamichanw
          You show

          (Cannot mix debug and release libraries.)

          What would you like people to say about this situation?

          K 1 Reply Last reply
          0
          • JonBJ JonB

            @Kamichanw
            You show

            (Cannot mix debug and release libraries.)

            What would you like people to say about this situation?

            K Offline
            K Offline
            Kamichanw
            wrote on last edited by Kamichanw
            #5

            @JonB Fine... I just want to figure out how to build c++ plugin properly and apply it to python project. Here is how I build and use my dll

            1. Open libray .pro file and click Build in debug mode.
            2. Use QPluginLoader as follows
            loader = QPluginLoader()
            loader.setFileName(str(KMCUI_PATH / "bin/kmcuiplugin.dll"))
            loader.load()
            

            Here is content of my library .pro file:

            TEMPLATE = lib
            QT += qml quick
            CONFIG += plugin qmltypes
            
            TARGET = $$qtLibraryTarget(kmcuiplugin)
            
            QML_IMPORT_NAME = KmcUI
            QML_IMPORT_VERSION = 1.0
            
            RESOURCES += ...
            
            HEADERS += ...
            
            SOURCES +=  ...
            
            DESTDIR = $$PWD/bin
            
            DISTFILES += ...
            
            CONFIG += install_ok
            
            
            JonBJ 1 Reply Last reply
            0
            • K Kamichanw

              @JonB Fine... I just want to figure out how to build c++ plugin properly and apply it to python project. Here is how I build and use my dll

              1. Open libray .pro file and click Build in debug mode.
              2. Use QPluginLoader as follows
              loader = QPluginLoader()
              loader.setFileName(str(KMCUI_PATH / "bin/kmcuiplugin.dll"))
              loader.load()
              

              Here is content of my library .pro file:

              TEMPLATE = lib
              QT += qml quick
              CONFIG += plugin qmltypes
              
              TARGET = $$qtLibraryTarget(kmcuiplugin)
              
              QML_IMPORT_NAME = KmcUI
              QML_IMPORT_VERSION = 1.0
              
              RESOURCES += ...
              
              HEADERS += ...
              
              SOURCES +=  ...
              
              DESTDIR = $$PWD/bin
              
              DISTFILES += ...
              
              CONFIG += install_ok
              
              
              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Kamichanw said in How to import c++ qml plugin to python project?:

              Open libray .pro file and click Build in debug mode.

              So have you tried building in Release mode instead and see whether the message is affected?

              K 1 Reply Last reply
              0
              • JonBJ JonB

                @Kamichanw said in How to import c++ qml plugin to python project?:

                Open libray .pro file and click Build in debug mode.

                So have you tried building in Release mode instead and see whether the message is affected?

                K Offline
                K Offline
                Kamichanw
                wrote on last edited by
                #7

                @JonB Yes, in Release mode, it shows that

                Cannot load library C:\Users\ASUS\Documents\Qt Project\cv-tools\3rdparty\KmcUI\bin\kmcuiplugin.dll: �Ҳ���ָ���ij�����
                
                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kamichanw
                  wrote on last edited by
                  #8

                  I tried to load this plugin by QQmlApplicationEngine::addPluginPath, which is the way I load successfully in C++. But it still shows

                  Unable to load library C:\Users\ASUS\Documents\Qt Project\cv-tools\3rdparty\KmcUI\bin\kmcuiplugin.dll: The specified program could not be found.
                  

                  But I'm pretty sure there exists such a dll.

                  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