Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.2.1, 4.7.2, 5.4.0 Beta
-
None
-
24a94ab833dac46790a58e8375dc226890994716
Description
QGraphicsTextItem does not support center or right alignment of html text.
Reproducible with the following example:
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsScene scene(0);
QGraphicsTextItem text(0,&scene);
text.setHtml("<h2 align=\"center\">hello</h2><h2 align=\"center\">world 12334345354444444444444444444444444</h2>123");
text.setPos ( QPointF(25,25 ));
QGraphicsView view(&scene);
view.show();
QTextEdit te;
te.setHtml("<h2 align=\"center\">hello</h2><h2 align=\"center\">world 12334345354444444444444444444444444</h2>123");
te.show();
return app.exec();
}
As a workaround, call setTextWidth to allow the framework to calculate the horizontal alignment of the text.