Hi all,
QTextDocument supports tab stops. For example QTextOption has setTabs()
and so you can call QTextDocument::setDefaultTextOption() and also
QTextBlockFormat has setTabPositions().
Obviously html doesn't support tabs and as multiple whitespaces are just
ignored.
But is there any way for tabs to be inserted via QTextCursor::insertHtml()
and/or QTextDocument::setHtml()?
There are features of QTextDocument that are hard to access without
insertHtml, but this is one feature that as far as I can tell is only
accessible via QTextCursor::insertText() and
QTextDocument::setPlainText().
I've been able to mix/match insertHtml() and insertText() to split up my
insertHtml() calls and insert tabs with insertText(). It sort of works
(see below), but I'm checking if there is a better solution...
Thanks,
Josh
QStringList tabText = text.split("\t");
text="";
for(int i=0; i<tabText.size(); i++)
{
myCursor->insertHtml(QString("<span
style='%2'>%1</span>").arg(tabText[i]).arg(effect));
if(i<tabText.size()-1)
myCursor->insertText("\t");
}
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest