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.
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. The main.cpp: #include "testplasmoid.h" #include <klocalizedstring.h> #include <QtQml/QQmlContext> #include <QtQml/QQmlApplicationEngine> #include <QtWidgets/QApplication> #include "ExampleAdaptor.h" #include "scriptlauncher.h" #include <QtDBus> #include <QtCore/QMetaObject> #include <QtCore/QByteArray> #include <QtCore/QList> #include <QtCore/QMap> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QVariant> #include <QDebug> #include <QtQml/QQmlExtensionPlugin> 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); 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" The CMakeList.txt is set as the follows: 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) set(testplasmoid_HEADERS testplasmoid.h scriptlauncher.h ExampleAdaptor.h) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Quick Core DBus Widgets ) add_library(plasma_applet_testplasmoid MODULE ${testplasmoid_SRCS} ${testplasmoid_HEADERS}) 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) Request you to please guide me on why the main function doesn't work in plasma5 and how can i fix it. There is no documentation available on C++/QML plasmoid/widgets for plasma 5 so asking for help here. Thanks, Aditya
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel