Multicolor text
-
Hi
I have a string constructed this way:
const auto text = QString { "#%1%2%3%4" } .arg(QString::number(n), -15) .arg(someText, -45) .arg(symbol, -2) .arg(QString::number(someNumber), -5);
How can I make the
%3
argument to be another color?The text is set to a label, so if I put
QString { "#%1%2<font color=\"red\">%3</font>%4" }
all the styles of the label are gone.
What can I do?
-
Hi
I have a string constructed this way:
const auto text = QString { "#%1%2%3%4" } .arg(QString::number(n), -15) .arg(someText, -45) .arg(symbol, -2) .arg(QString::number(someNumber), -5);
How can I make the
%3
argument to be another color?The text is set to a label, so if I put
QString { "#%1%2<font color=\"red\">%3</font>%4" }
all the styles of the label are gone.
What can I do?
@user4592357 Do you set the labels text for mat to rich text somewhere in you code?
setTextFormat(Qt::TextFormat)
-
@user4592357 Do you set the labels text for mat to rich text somewhere in you code?
setTextFormat(Qt::TextFormat)
@kenchan yeah, doesn't help
-
@JNBarchan Yes that is what I meant, and of course one should pass it Qt::RichText if you want it to understand rich text.
-
@kenchan
I know, but you can never be sure here what users are actually writing in their code in these cases :) @user4592357 may be fine for this, but others sometimes aren't....@JNBarchan yes, i tried that.
and sorry to confuse you, of course i understood. if i didn't know what he meant, i'd just ask :)