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. Qt User Plugins & iOS
QtWS25 Last Chance

Qt User Plugins & iOS

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 1.8k 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by dheerendra
    #1

    Hi All

    I have developed Custom Qt Plugins(libDataStore.so) and used QPluginLoader to load the plugin in Android. It works fine..

    How to use the same plugin in iOS ?. I know iOS talks about static plugin etc. When I build the same plugin using iOS kit, it build libDataStore.a. This is static lib.

    How do i use this in iOS ? How to bundle this ? Does QPluginLoader works for this ? See the following sample code

    QPluginLoader loader;
        loader.setFileName("libDataStore.a");
        if(loader.load()){
            qDebug() << Q_FUNC_INFO << " Plugin load successfull" << endl;
            QObject *obj = loader.instance();
            if (obj==NULL){
                qCritical() << "Plugin load failed. Please check "<<endl;return;
            }
            IDataStore *collector = qobject_cast<IDataStore*>(obj);
            connect(this,SIGNAL(storeDB()),obj,SLOT(start()));
        }else {
            qCritical() <<"Plugin load failed. Please check ="<< endl;return;
        }
    
    
    Any inputs on this.

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's explained here.

      Just in case and IIRC, since Qt 5.9, you should also be able to build Qt dynamically on iOS but it's not yet currently fully automated for the bundling part so you might want to stay with the default current static build.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by dheerendra
        #3

        Thank @SGaist . Here is the complete info if somebody requires.

        Plugin Side -

        1. First build your Qt plugin as static lib. For this place the following configuration in your plugin pro file.
          CONFIG +=plugin static
        2. My Plugin name is libDataStore.a & class name of the plugin is DataStore & Interface name is IDataStore
        3. Inside the constructor of DataStore, set the object name
          e.g this.setObjectName("DataCollectorPlugin")
        4. libDataStore.a is present in the directory called /Users/dheeru/Qt/bins

        App Side -

        1. Place the configuration in application pro file like this
          LIBS += -L/Users/dheeru/Qt/bins -lDataStore
        2. Q_IMPORT_PLUGIN(DataStore) in main.cpp. Argument for the macro should match the classname
        3. Use QPluginLoader::staticInstances function. This will return the QObjects list. Since there may be many plugins, objectName is useful here.
        4. After this type cast the required object to Appropriate interface.
        QObjectList objList = QPluginLoader::staticInstances();
            foreach(QObject *obj1, objList){
                qDebug() <<" IOS Load successful =" << obj1->objectName() << endl;
                IDataStore *collector = qobject_cast<IDataStore*>(obj1);
                if(collector!=NULL){
                    connect(this,SIGNAL(storeDB()),obj1,SLOT(start()));
                }
            }
        

        Once you have object with you, rest of the process is same.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        2

        • Login

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