Draw rich text with QPainter
is there a way to draw fixed text that has subscripts. My goal is to have something like: "K_max=K_2 . 3" QString equation="K_max=K_2 . 3"; painter.drawText( QRect(x, y , width, y+height), Qt::AlignLeft|Qt::AlignVCenter, equation); I also tried formatting the text using html tags but it didn't help (tags got printed with the text): QString equation="<p>K<sub>max</sub></p>=<p>K<sub>2</sub></p>.3" Here is a full example using rich text of QTextDocument. mainWindow.cpp: #include "mainWindow.h" void MainWindow::paintEvent(QPaintEvent*) { QPainter painter(this); QTextDocument td; td.setHtml("K<sub