UriTK
13th April 2019, 00:21
So, I'm trying to add an outline into a QTextEdit via CharFormat. For some reason, I can't seem to get the format to actually apply.
Let me go through some things I've tried.
This doesn't change current nor future text, even when I do set it to select everything, or try different cursor positions.
QTextCharFormat outline;
outline.setTextOutline(QPen(Qt::black, 2));
QTextEdit->mergeCurrentCharFormat(outline);
This is about the point where I started getting desperate, so I tried to instead simulate an outline via setting text-shadow on the stylesheet.
QTextEdit->setStyleSheet("text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000")
Even though I've both tried to do this standalone and tried adding it on top of other stylesheet changes that were functioning via
style.append("; text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000;");
it does not actually do anything either.
The only way I've been to apply a charformat to a QTextEdit on my code was doing it alongside an insertText operation, which was
QTextEdit->textCursor().insertText(qstring, qtextcharformat);
but I'd rather not rework this code to use insertText on this QTextEdit I want to change just so I can set an outline.
Let me go through some things I've tried.
This doesn't change current nor future text, even when I do set it to select everything, or try different cursor positions.
QTextCharFormat outline;
outline.setTextOutline(QPen(Qt::black, 2));
QTextEdit->mergeCurrentCharFormat(outline);
This is about the point where I started getting desperate, so I tried to instead simulate an outline via setting text-shadow on the stylesheet.
QTextEdit->setStyleSheet("text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000")
Even though I've both tried to do this standalone and tried adding it on top of other stylesheet changes that were functioning via
style.append("; text-shadow: 0px 2px #000000, 0px -2px #000000, -2px 0px #000000, 2px 0px #000000;");
it does not actually do anything either.
The only way I've been to apply a charformat to a QTextEdit on my code was doing it alongside an insertText operation, which was
QTextEdit->textCursor().insertText(qstring, qtextcharformat);
but I'd rather not rework this code to use insertText on this QTextEdit I want to change just so I can set an outline.