开发者

Change QML font.pointSize in C++

开发者 https://www.devze.com 2023-03-26 18:21 出处:网络
I have managed to change the \"color\" property of QML text with C++ using this: theText->setProperty(\"color\", \"red\");

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消