Hi all,
I want to draw text input from keyboard, and display like Japanese style, from right to left and the top to bottom.
I had implemented paintEvent() method in my class to draw text from the top to bottom, my class is inherited from QTextEdit class:
{
p.translate(0, 0);
p.rotate(90);
for(int i=0; i< this->document()->toPlainText().size(); ++i) {
QString letter
= this
->document
()->toPlainText
().
mid(i,
1);
p.save();
p.translate(i * 12, 0);
p.rotate(-90);
p.setLayoutDirection(Qt::LeftToRight);
p.drawText(this->rect(), Qt::AlignRight|Qt::AlignTop|Qt::TextWordWrap|Qt::TextWrapAnywhere, letter);
p.restore();
}
}
void MyText::paintEvent(QPaintEvent *)
{
QPainter p(viewport());
p.translate(0, 0);
p.rotate(90);
for(int i=0; i< this->document()->toPlainText().size(); ++i) {
QString letter = this->document()->toPlainText().mid(i,1);
p.save();
p.translate(i * 12, 0);
p.rotate(-90);
p.setLayoutDirection(Qt::LeftToRight);
p.drawText(this->rect(), Qt::AlignRight|Qt::AlignTop|Qt::TextWordWrap|Qt::TextWrapAnywhere, letter);
p.restore();
}
}
To copy to clipboard, switch view to plain text mode
And result like image:
image.PNG
But I want to text when fit height, it auto word wrap to new column like below image:
Result.PNG
How to wrap the text like above image?
Thanks so much!
Best regards!
Bookmarks