How to change the background of a text bloc in a text document in Qt

is there a way to change the background color of a QTextBlock in a QTextDocument without using a subclass of QAbstractTextDocumentLayout. I have tried many ways and the effects are null. I am trying from the textCursor() method of a QPlainTextEditor and it seems practically everything is const.


You could try the merge methods:

QTextCursor cur = edit->textCursor();
QTextCharFormat fmt;

Could this example help you ?

You can find it also in QtDemos, on Demonstrations->Text Edit.

Hope it helps!

Need Your Help

Handle -0 from Database Value in C++

c++ database negative-zero

At present I am working on piece of C++ code in which I need to read data from a database, and if database value is non-zero, then I need to apply some further logic.

running a php function inside javascript code

javascript php jquery

I hope to run a php code inside a javascript code too and I do like that :