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

QToolTip width calculation must account for <br> breaks in long lines.

    XMLWordPrintable

Details

    Description

      Consider this code:

      #include <QApplication>
      #include <QLabel>
      #include <QHBoxLayout>

      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);

      QWidget top;

      QHBoxLayout layout;

      const QString s("<table>"
      "<tr><td>Line 1</td></tr>"
      "<tr><td>Line 2%1</td></tr>"
      "<tr><td>Line 3</td></tr>"
      "</table>");
      const QString line2b("Line 2b");

      { QLabel *const lbl = new QLabel(&top); lbl->setText("First Label"); lbl->setToolTip(s.arg(" " + line2b)); layout.addWidget(lbl); } { QLabel *const lbl = new QLabel(&top); lbl->setText("Second Label"); lbl->setToolTip(s.arg("<br>" + line2b)); layout.addWidget(lbl); } { QLabel *const lbl = new QLabel(&top); lbl->setText("Third Label"); lbl->setToolTip(s.arg("<table><tr><td>" + line2b + "</td></tr></table>")); layout.addWidget(lbl); }

      top.setLayout(&layout);

      top.show();
      return app.exec();
      }

      This is not about text wrapping/layoutting, but the yellow background rectangle, which in the case of Second Label has an incorrectly computed width.

      Attachments

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

        Activity

          People

            menard Alexis Menard (closed Nokia identity) (Inactive)
            fenglich Frans Englich (closed Nokia identity)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes