Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-312

QGraphicsTextItem does not support center or right alignment of html text

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.4.1
    • 4.2.1, 4.7.2, 5.4.0 Beta
    • Widgets: GraphicsView
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peppe Giuseppe D'Angelo
            admin Administrator
            Votes:
            4 Vote for this issue
            Watchers:
            15 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes