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

QTextEdit: Setting style on a DOM element removes globally set style from it

    XMLWordPrintable

Details

    • Linux/X11

    Description

      When an element has a style property, only CSS from that property is applied to it, not a combination of local and global CSS, as one would expect.

      Consider the following code:

      #include <QtWidgets/QApplication>
      #include <QtWidgets/QTextEdit>
      
      int main(int argc, char **argv) {
          QApplication app(argc, argv);
          QTextEdit edit;
          edit.setHtml(
              "<!doctype html>\n"
              "<html>\n"
              "    <head>\n"
              "        <style type='text/css'>td { border: 5px solid red; }</style>\n"
              "    </head>\n"
              "    <body>\n"
              "        <table>\n"
              "            <tr>\n"
              "                <td>First cell</td>\n"
              "                <td style='text-align: left'>Second cell</td>\n"
              "            </tr>\n"
              "        </table>\n"
              "    </body>\n"
              "</html>\n"
          );
          edit.show();
          return app.exec();
      }
      

      Second cell does not have the red border, but it should. A screenshot is attached.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            mandriver Dmitry Shachnev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes