tags:

views:

25

answers:

1

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

    QTextBlockFormat bfmt;
    bfmt.setObjectIndex(0);

What this code does?

ADDED: 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;
     bfmt.setObjectIndex(-1);
     cursor.mergeBlockFormat(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;
    bfmt.setObjectIndex(0);
    m_textCursor.mergeBlockFormat(bfmt);
    m_textEdit->setTextCursor(m_textCursor);

Please explain me why?

A: 

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.

Arnold Spence
Thanks for answer, but please explain me what I had written in the ADDED block above. I hopped that the answer of my question will help me understand the Qt demo code but I need more help, please.
Narek