QTextCursor beginEditBlock bug?

  • I've run into a problem using QTextCursor::beginEditBlock(). It appears to be a bug but perhaps I'm just not using it properly. The following code snippet illustrates the problem (Qt 4.8):

    @ qDebug()<<"root frame="<<ui->textEdit->document()->rootFrame();
    QTextCursor tc=ui->textEdit->textCursor();

    // create a table
    QTextTable *cframe=tc.insertTable(2,2);
    qDebug()<<"table pointer = "<<cframe;
    qDebug()<<"rtf cursor table = "<<tc.currentTable();
    qDebug()<<"rtf cursor current frame="<<tc.currentFrame();

    If the lines tc.beginEditBlock() and tc.endEditBlock() are commented out the above code works perfectly but if the lines are included then the currentTable and currentFrame lines return the root frame instead of the table frame. However the cursor tc is positioned properly in both cases as illustrates by the text insert (the above code is a simplified version of my real code but illustrates the basic problem).

    Has anyone else run into this problem and found a solution? I don't really want to remove the beginEditBlock() directive as it slows down the processing considerably but I may have to if I can't solve the problem.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.