Hi Mike,

I got your idea. Thank you very much. :)

On Mon, Jan 27, 2025 at 9:12 AM Mike Trahearn <
miketrahe...@codeceptsoftware.com> wrote:

> Hi Alexander,
>
> Yes, it is possible, with a simple implementation as follows:
>
> You simply need two Text boxes.
>
> Rectangle {
> id: progressBar
>
> property string text
> property real value: 0.25
>
> color: “white”
>
> Text {
> color: “red”
> text: progressBar.text
> }
>
> Rectangle {
> // on top of the red text
> color: “red”
> height: parent.height
> width: parent.width * progressBar.value
> }
>
> Text {
> // must be positioned exactly the same and have the same string and font
> properties as the red text.
> color: “white”
> text: progressBar.text
> }
> }
>
> If you want to stick with a single Text element then you may want to
> consider MultiEffect or something similar that can change colors at the
> fragment level.
> Note in this case, you will need to mind your anti-aliasing because you’ll
> be messing around with those fragments. In the simple case above, this is
> taken care of for you.
> It really depends on how dynamic your colors are going to be.
>
> Kind regards,
>
> Mike
>
>
> *Director, Codecept Software Pty Ltd*
> miketrahe...@codeceptsoftware.com
> +61 (0) 467 084 485
> ACN: 679 947 347
> ABN: 55 679 947 347
> Book a Consultation <https://calendar.app.google/2gEvFrCYj5gCodkc7>
>
> On 27 Jan 2025, at 11:08 am, Alexander Dyagilev <alervd...@gmail.com>
> wrote:
>
> Hello,
>
> Is it possible to achieve something like this in QML?
>
> <7c51c428-735a-476d-95b0-da06e90f28d3.png>
>
> I would like to draw a text on a non-solid background. E.g. some areas can
> be black, some can be white, red, etc. Text should automatically change its
> color so it stays visible and readable.
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
>
>
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to