I traced through QTextDocument : : drawContents (QPainter*) in hopes of QTextFormat's properties being used to control the painter, as i found QTextFormat : : setProperty ( int, QVariant) and guessed we could set QTextFormat : : UserProperty as vertical or horizontal then use this property when using the painter. however, i got lost.![Frown](images/smilies/frown.png)
My ideas is to re-implement QTextDocument : : drawContents (QPainter * ) or other functions to get the QTextFormat's properties that have been set by users, According to the UserProperty rotate the painter or not. is this a bad idea?
// format might be sub class of QTextFormat, for example, QBlockTextFormat
{
if (format.
property(QTextFormat::UserProperty).
toInt() == CustomTextDocument
::Vertical) {
painter->save();
painter->translate( xoff, yoff);// to correct the text's position
painter->rotate(90);
// call the basic class's function to draw the text, however rotated.
painter->restore();
}
else
// if no vertical text is needed, call basic class's function
}
CustomTextDocument::someFunction(QPainter *painter, QTextFormat *format)
// format might be sub class of QTextFormat, for example, QBlockTextFormat
{
if (format.property(QTextFormat::UserProperty).toInt() == CustomTextDocument::Vertical)
{
painter->save();
painter->translate( xoff, yoff);// to correct the text's position
painter->rotate(90);
QTextDocument::someFunctioin(painter, format);
// call the basic class's function to draw the text, however rotated.
painter->restore();
}
else
QTextDocument::someFunction(painter, format);
// if no vertical text is needed, call basic class's function
}
To copy to clipboard, switch view to plain text mode
Bookmarks