std::string passed from c++ to qml is not set properly
-
Hello,
I am trying to set a std::string to a text in qml, the first character always shows as junk character as.
reference code used :
Bt.hclass Bt : public Qul::Singleton<Bt> { public: Qul::Property<std::string> d; };
sample.qml
import QtQuick 2.0 import QtQuickUltralite.Extras 2.0 Rectangle { id: root property string k: Bt.d; Text { id: strname text: k } }
and the string value is set from main.cpp as Bt::instance().d.setValue("yes");
Why the first character is always junk? how to fix this?I am using qtformcu v2.1.0 in windows10.
-
Hi,
Qt for MCUs being a commercial only distribution of Qt, you may have to wait a bit longer before getting an answer. In between:
What happens if you use QString instead of std::string ?
What happens if you append Bt.d to as string ?
What happens if you set your Text object text property directly toBt.d
?Where do you setup your Bt singleton ?
-
Hi,
What happens if you use QString instead of std::string ? - I guess QString is not available in QtforMCU.
What happens if you append Bt.d to as string ? - If I append Bt.d in sample.qml i.e; hardcoded like Bt.d = "test"; the text is displayed without any junk character.
What happens if you set your Text object text property directly to Bt.d ? -it is same result, first character is junk.
Where do you setup your Bt singleton ? - All files in a same folder.
-
My last question was: how do you set it up in your code ?
-
@SGaist I am not sure what exactly "how do you set it up in your code ?" means, but if it is about creating instance of Bt singleton, this will be created by qul in generated code, so this global instance can be accessed anywhere in the code. Or if it is about set the value for Bt.d it is like
Bt::instance().d.setValue("yes");
as mentioned in my post.
-