<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><!--StartFragment--><span style=" font-family:'Arial'; font-size:12pt;">One</span><span style=" font-family:'Courier New'; font-size:12pt;">Two</span><span style=" font-family:'Arial'; font-size:12pt;">Three</span><!--EndFragment--></p>
C++ (Qt)#include <QtGui/QApplication>#include <QTextEdit>#include <QTextCursor>#include <QTextCharFormat>#include <QDebug> int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextEdit t; t.setHtml("<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> " "<!--StartFragment-->" "<span style=\" font-family:'Arial'; font-size:12pt;\">One</span>" "<span style=\" font-family:'Courier New'; font-size:12pt;\">Two</span>" "<span style=\" font-family:'Arial'; font-size:14pt;\">Three</span>" "<!--EndFragment-->" "</p>"); QTextCursor cursor = QTextCursor(t.document()); //cursor.setPosition(0); while (!cursor.atEnd()) { qDebug()<<cursor.charFormat().font(); cursor.movePosition(QTextCursor::NextCharacter); } return 0;}
QFont( "Arial,12,-1,5,50,0,0,0,0,0" ) QFont( "Arial,12,-1,5,50,0,0,0,0,0" ) QFont( "Arial,12,-1,5,50,0,0,0,0,0" ) QFont( "Arial,12,-1,5,50,0,0,0,0,0" ) QFont( "Courier New,12,-1,5,50,0,0,0,0,0" ) QFont( "Courier New,12,-1,5,50,0,0,0,0,0" ) QFont( "Courier New,12,-1,5,50,0,0,0,0,0" ) QFont( "Arial,14,-1,5,50,0,0,0,0,0" ) QFont( "Arial,14,-1,5,50,0,0,0,0,0" ) QFont( "Arial,14,-1,5,50,0,0,0,0,0" ) QFont( "Arial,14,-1,5,50,0,0,0,0,0" )
[quote author=Rcus link=topic=8877.msg49915#msg49915 date=1237207922] QTextCursor cursor = QTextCursor(t.document()); //cursor.setPosition(0); while (!cursor.atEnd()) { qDebug()<<cursor.charFormat().font(); cursor.movePosition(QTextCursor::NextCharacter); }