Setting the default color of ALL text elements
-
Doing some work with QML elements, and I would like every Text-element to have a default color if none is given to them. Instead of giving all Text-elements the default color of black, I would like to set a custom color. Is this possible?
I've thought about just making a custom component (with a few default properties) and replace every instance of the Text-element with this. However, there are A LOT of Text-elements and I would possibly break many components if I try to go this route.
Is there anything I can do in C++, maybe? -
If you are using QtQuick.Controls (1 or 2) you can use styles to apply custom look to all components.
If you are talking about basic Text component, then there is a way: create Text.qml file (exactly the same name as the basic type), set the color there, and then make sure it's directory is imported in your other qml files. The QML engine should pick up your new implementation instead of basic type.