Reputation: 1
I'm using void QPainter::drawText(const QRectF &rectangle, const QString &text, const QTextOption &option = QTextOption()
method to draw some text.
It lets me to align text as i wish (in the center of rectangle
, for example).
Now, i need to do the same thing, except i need to draw one part of text
with
some font and the other part with another.
For example, if text is "Hello world", i want "Hello" to be drawn with Arial and "World" with Times New Roman, but it should still be aligned with the center of rectangle
.
What is the best way to achieve that?
Upvotes: 0
Views: 2758
Reputation: 128
you can try with this :
QPainter painter(this);
painter.setFont(QFont("Arial", 12));
painter.drawText(rect(), Qt::AlignCenter, "Hello");
Upvotes: 1