Reputation: 2832
I have QML component with TextEdit:
TextEdit {
...
font: settings.myFont
font.preferShaping: false
when load the component I get error qml Can't create component <path_to_my_qml>: Property has already been assigned a value
pointing to the line font.preferShaping: false
.
I try to comment the line font.preferShaping: false
and set the property on the c++ side by:
QFont Settings::myFont() const
{
...
font.setStyleStrategy(QFont::PreferNoShaping);
return font;
}
but then the appearance of the text matches the default value of the font.preferShaping
property, which is true.
How can I set the font.preferShaping
property to false without errors?
Ultimately, I need to achieve the same display of a text in QML and on c++ side, where the text draws via updatePaintNode
:
QSGNode* Text::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintNodeData*)
{
...
painter.setFont(settings.myFont());
painter.drawText(rect, alignment(), m_textParams.text());
...
}
Upvotes: 0
Views: 80
Reputation: 796
How about setting the property after the onFontChanged signal is emitted:
Text {
id: text
font: settings.myFont
onFontChanged: {
text.font.preferShaping = false;
}
}
Upvotes: 0