[Interest] Lists and QTextEdit
Graham Labdon
Graham.Labdon at avalonsciences.com
Tue Jan 17 10:41:56 CET 2012
Hi
I am trying to add a numeric list to a QTextEdit.
So I have a QDialog with a QTextEdit and a button which when pressed should add an item to the list.
This is my code so far (for when the button is pressed)
QTextCursor cursor = ui->textEdit->textCursor();
QTextBlockFormat listBlockFormat;
QTextCharFormat listCharFormat;
QString listItemText = "The item";
QTextListFormat listFormat;
listFormat.setIndent(1);
listFormat.setStyle(QTextListFormat::ListDecimal);
cursor.insertBlock();
cursor.beginEditBlock();
cursor.setBlockFormat(listBlockFormat);
cursor.setCharFormat(listCharFormat);
cursor.insertText(listItemText);
QTextList *textList = cursor.createList(listFormat);
textList->add(cursor.block());
cursor.endEditBlock();
This adds list items but they always have the decimal value of 1 -
1. The Item
I know this is because I create a new list every time, but cannot see how to make this work
Any suggestions would be welcome
Thanks
Graham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120117/dbee1bd6/attachment.html>
More information about the Interest
mailing list