Solved Unable to assign [undefined] to QString
-
Hello,
I am developing a kde plasmoid and cannot get basic communication between cpp and qml. I think everything is returning the correct type but I am still getting undefined. Here are my files:
unixtime.h
#ifndef UNIXTIME_H #define UNIXTIME_H #include <Plasma/Applet> class unixtime : public Plasma::Applet { Q_OBJECT Q_PROPERTY(QString nativeText READ nativeText CONSTANT) public: unixtime( QObject *parent, const QVariantList &args ); ~unixtime(); QString nativeText() const; QString text() const; private: QString m_nativeText; }; #endif
unixtime.cpp
#include "unixtime.h" #include <klocalizedstring.h> #include <QString> unixtime::unixtime(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), m_nativeText(i18n("Text coming from C++ plugin")) { } unixtime::~unixtime() { } QString unixtime::nativeText() const { return QString("Test"); return m_nativeText; } QString unixtime::text() const { return QString("test"); } K_EXPORT_PLASMA_APPLET_WITH_JSON(unixtime, unixtime, "metadata.json") #include "unixtime.moc"
main.qml
import QtQuick 2.1 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents Item { Plasmoid.fullRepresentation: ColumnLayout { anchors.fill: parent Image { Layout.fillHeight: true Layout.fillWidth: true fillMode: Image.PreserveAspectFit source: "../images/pairs.svgz" } PlasmaComponents.Label { Layout.alignment: Qt.AlignCenter text: plasmoid.nativeInterface.text } } }
Thank you for your help!
Also this error is occurring on the text object -
Hi and welcome to devnet,
Since you are developing a KDE plasmoid, you should rather bring this question to the KDE folks.
-
@SGaist thank you for your reply. I'll pass my question on to the KDE folk!