c++ – What is object index of QTextFormat? – Education Career Blog

The function int QTextFormat::objectIndex () const returnes an object index. What is it? And what if I do the following:

    QTextBlockFormat bfmt;

What this code does?

Here there is a function void TextEdit::textStyle(int styleIndex). This function is for adding a list into QTextEdit, or making it a normal (standard text). In the function mentioned above there is a code snippet like this:

 } else {
     // ####
     QTextBlockFormat bfmt;

This code snippet is in order to make list a standard text. But it does not work and only works when I write

    QTextBlockFormat bfmt;

Please explain me why?


QTextOjbects are used to group parts of a QTextDocument. Some text objects would be QTextList, QTextFrame, QTextTable etc. Each of these text objects have an index. The ojbectIndex of a QTextFormat associates the format object with a text object.

Your code above would associate bfmt with the text object with index 0.

Leave a Comment