I have managed to change the "color" property of QML text with C++ using this:
theText->setProperty("color", "red");
but if I try
theText->setProperty("font.pointSize", 20);
then nothing开发者_C百科 happens(it's not that size), I've tried this with other things that include a "." but none seem to work, I think the "." may be part of the problem. I'd really appreciate if someone could help me change the QML font size using C++.
Look for actual property name. And as far as i know there is no sub-properties in QObjects... So you need something like this:
QFont f = theText->property("font").value<QFont>();
f.setPointSize(20);
theText->setProperty("font",f);
精彩评论