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

Regression in QTextTable: border-collapse cell border rendering broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.1, 6.8.3, 6.9.0
    • GUI: Text handling
    • None

    Description

      This change for QTBUG-125763 (732962d604e7469f9a9f02fe0cd3d1fd04caddb8, appears in Qt 6.7.1) breaks the intended and documented behavior of the table cell border rendering (QTBUG-36152):

      https://doc.qt.io/qt-6/qtexttableformat.html#setBorderCollapse

      "Setting the border property to a minimum value of 1 will render a one pixel solid inner table grid using the borderBrush property and an outer border as specified"

      The regression is caused by the logic now expecting at least one of the four "border" properties to be set in the cell's format.

      +    bool cellBorderConfigured = (cell.format().hasProperty(QTextFormat::TableCellLeftBorder) ||
      +                                 cell.format().hasProperty(QTextFormat::TableCellTopBorder) ||
      +                                 cell.format().hasProperty(QTextFormat::TableCellRightBorder) ||
      +                                 cell.format().hasProperty(QTextFormat::TableCellBottomBorder));
      
      ...
      
      -    drawTableCellBorder(cellRect, painter, table, td, cell);
      +    if (cellBorderConfigured)
      +        drawTableCellBorder(cellRect, painter, table, td, cell);
      

      Reproduced by:

          QTextDocument *doc = document();
      
          doc->clear();
      
          QTextCursor c(doc);
          c.insertText("Foo");
      
          QTextTable *table = c.insertTable(10, 10);
          QTextTableFormat f;
          f.setBorderCollapse(true);
          f.setBorder(1);
          f.setWidth(200);
          table->setFormat(f);
      
          QTextTableCell cell = table->cellAt(5, 5);
          QTextTableCellFormat cf;
          cf.setLeftBorder(2);
          cf.setLeftBorderBrush(Qt::green);
          cf.setLeftBorderStyle(QTextFrameFormat::BorderStyle_Solid);
          cell.setFormat(cf);
      

      A complete reproducer is attached.

      tests/manual/qtexttableborders does also shows different results when build against Qt 6.7.0 and 6.7.1.

      Attachments

        1. qt_texttable_6.7.0.png
          3 kB
          Nils Jeisecke
        2. qt_texttable_6.7.1.png
          3 kB
          Nils Jeisecke
        3. qtexttable-regression.tgz
          2 kB
          Nils Jeisecke

        Issue Links

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

          Activity

            People

              santhoshkumar Santhosh Kumar Selvaraj
              njeisecke Nils Jeisecke
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes