<div dir="ltr"><div><div>Hi, I am currently trying to create a plasma 5 widget/plasmoid for interaction with a python application using Dbus. I am using Qml/C++ for building the plasmoid. I am trying to use K Develop 5 to build the widget but am facing many errors in the process. <br><br></div>The plasmoid sends and receives string values to the python application using QT DBus. The plasmoid builds without error inside KDevelop 5 but the dbus adaptor is not being initialized and neither are my other classes within the main function of the plasmoid. Only the QML file is displayed with no connection to my main function when added to the desktop or tested with execute in KDevelop 5.<br><br></div>The main.cpp: <br><br>    #include "testplasmoid.h"<br>    #include <klocalizedstring.h><br>    #include <QtQml/QQmlContext><br>    #include <QtQml/QQmlApplicationEngine><br>    #include <QtWidgets/QApplication><br>    #include "ExampleAdaptor.h"<br>    #include "scriptlauncher.h"<br>    #include <QtDBus><br>    #include <QtCore/QMetaObject><br>    #include <QtCore/QByteArray><br>    #include <QtCore/QList><br>    #include <QtCore/QMap><br>    #include <QtCore/QString><br>    #include <QtCore/QStringList><br>    #include <QtCore/QVariant><br>    #include <QDebug><br>    #include <QtQml/QQmlExtensionPlugin>
<pre>    testplasmoid::testplasmoid(QObject *parent, const QVariantList &args)
        : Plasma::Applet(parent, args),
         m_nativeText(i18n("Text coming from C++ plugin"))
    {
    }

    testplasmoid::~testplasmoid()
    {
    }

    QString testplasmoid::nativeText() const
    {
          return m_nativeText;
     }

    int main(int argc, char *argv[]) 
    {
     QApplication app(argc, argv);
     KDEDbusAdaptor KDEDbusAdaptor(&app); [<----- Initializing the Class/Dbus Adaptor]
     ScriptLauncher launcher; [<------ Initializing the Class]
     QQmlApplicationEngine engine;
     engine.rootContext()->setContextProperty("KDEDbusAdaptor", &KDEDbusAdaptor);
     engine.rootContext()->setContextProperty("scriptLauncher", &launcher);<br>     QObject *topLevel = engine.rootObjects().value(0);
     QObject::connect(topLevel,SIGNAL(submitTextField(QString)), &KDEDbusAdaptor,SLOT(sendQueryFunctionSlot(QString)));
     QObject::connect(topLevel,SIGNAL(senddbussignal(QString)), &KDEDbusAdaptor,SLOT(emptyslot(QString)));
     return app.exec(); 
    }

    K_EXPORT_PLASMA_APPLET_WITH_JSON(testplasmoid, testplasmoid, "metadata.json")
    #include "testplasmoid.moc"</pre><br><pre><code>The CMakeList.txt is set as the follows:<br><br>    add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.testplasmoid\")
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)

    set(testplasmoid_SRCS
    main.cpp
    scriptlauncher.cpp
    ExampleAdaptor.cpp)<br><br> </code><code><code>   set(testplasmoid_HEADERS
    testplasmoid.h
    scriptlauncher.h
    ExampleAdaptor.h)</code> <br><br>    find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
    Quick
    Core
    DBus
    Widgets
    )

    add_library(plasma_applet_testplasmoid MODULE ${testplasmoid_SRCS} </code><code><code>${testplasmoid_HEADERS}</code>)
    kcoreaddons_desktop_to_json(plasma_applet_testplasmoid package/metadata.desktop SERVICE_TYPES plasma-applet.desktop)
    target_link_libraries(plasma_applet_testplasmoid
                           Qt5::DBus
                           Qt5::Gui
                           Qt5::Qml
                           Qt5::Quick
                           Qt5::Widgets
                           KF5::Plasma
                           KF5::I18n)

     target_link_libraries(plasma_applet_testplasmoid ${QT_QTDECLARATIVE_LIBRARY})                      
     install(TARGETS plasma_applet_testplasmod DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
     plasma_install_package(package org.kde.testplasmoid)<br><br></code></pre><pre><code><span style="font-family:arial,helvetica,sans-serif">Request you to please guide me on why the main function doesn't work in plasma5 and how can i fix it.</span><span style="font-family:arial,helvetica,sans-serif"><br>There is no documentation available on C++/QML plasmoid/widgets for plasma 5 so asking for help here. </span><br><br></code></pre><pre><span style="font-family:arial,helvetica,sans-serif"><code>Thanks,<br></code></span><code><span style="font-family:arial,helvetica,sans-serif">Aditya</span><br></code></pre></div>