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

Wrong width for cells when Using <br> inside richtext tabels

    XMLWordPrintable

Details

    Description

      When using <br> inside richtext tabels the <br> tag correctly breaks the line into two, but the width of the cell does not seem to be calculated properly and is the width of both lines.
      This is true for some widgets like QTextbrowser and QTextedit, QLabel seems to display correctly.
      Using <p> produces cells of the correct width.

      See the following sample:
      #include <QApplication>
      #include <QDialog>
      #include <QTextbrowser>
      #include <QTextedit>
      #include <QLabel>
      #include <QHBoxLayout>

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      QString s =
      " using p this table is ok:"
      "<table border=2>\n"
      "<tr>\n"
      "<td>\n"
      // "<p><img src=\"x.png\"></p><p><img src=\"x.png\"></p>\n"
      "</td><td>\n"
      "<p>Some</p><p> text.</p>\n"
      "</td>\n"
      "</tr>\n"
      "</table>\n"

      "using br this table is too wide in some Widgets"
      "<table border=1>\n"
      "<tr>\n"
      "<td>\n"
      // "<img src=\"x.png\"><br><img src=\"x.png\">\n"
      "</td><td>\n"
      "Some<br>text.\n"
      "</td>\n"
      "</tr>\n"
      "</table>\n"
      ;

      QTextBrowser *browser = new QTextBrowser;
      browser->setHtml(s);

      QTextEdit *editor = new QTextEdit;
      editor->setHtml(s);

      QLabel *label = new QLabel;
      label->setText(s);

      QHBoxLayout *layout = new QHBoxLayout;

      layout->addWidget(browser);
      layout->addWidget(editor);
      layout->addWidget(label);
      QDialog *dia = new QDialog();

      dia->setLayout(layout);
      dia->show();
      return a.exec();
      }

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            dettman Dean Dettman (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes