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

Using an HTML table in a tooltip, then there is extra space added between the bottom of the table and the end of the tooltip box

    XMLWordPrintable

Details

    Description

      When using an HTML table in a tooltip, then there is extra space added between the bottom of the table and the bottom of the tooltip box. This only happens if a column in the table contains a relatively long string.

      The following example reproduces the problem. Note that only the tool tip with the long string ("This is a long name 1") exhibits the problem. The tool tip with the shorter string ("Name 1") does not have this issue.

      #include <QtGui>

      class MainWindow : public QMainWindow
      {

      public:
      MainWindow(QWidget *parent = 0)
      : QMainWindow(parent)

      { QWidget *w = new QWidget( this ) ; QVBoxLayout *l = new QVBoxLayout( w ) ; QLabel *lab = new QLabel( "This label has a tooltip with long names" ) ; lab->setTextFormat( Qt::RichText ); lab->setToolTip( this->tooltip( true ) ) ; l->addWidget( lab ) ; lab = new QLabel( "This label has a tooltip with short names" ) ; lab->setTextFormat( Qt::RichText ); lab->setToolTip( this->tooltip( false ) ) ; l->addWidget( lab ) ; setCentralWidget( w ) ; }

      QString tooltip( bool long_names )

      { QTextDocument doc ; QTextCursor cursor( &doc ) ; QTextTable *table ; QTextTableFormat format_table ; QTextTableCell cell ; QTextCursor cellCursor ; table = cursor.insertTable( 2, 2 ) ; format_table.setCellSpacing( 0 ) ; format_table.setCellPadding( 3 ) ; format_table.setBorder( 1 ) ; table->setFormat( format_table ) ; cell = table->cellAt( 0, 0 ) ; cellCursor = cell.firstCursorPosition(); cellCursor.insertText( ( long_names == true ) ? "This is a long name 1" : "Name 1" ) ; cell = table->cellAt( 0, 1 ) ; cellCursor = cell.firstCursorPosition(); cellCursor.insertText( "Value 1" ) ; cell = table->cellAt( 1, 0 ) ; cellCursor = cell.firstCursorPosition(); cellCursor.insertText( ( long_names == true ) ? "This is a long name 2" : "Name 2" ) ; cell = table->cellAt( 1, 1 ) ; cellCursor = cell.firstCursorPosition(); cellCursor.insertText( "Value 2" ) ; return( doc.toHtml() ) ; }

      } ;

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      MainWindow w;
      w.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
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes