Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextDocument HTML table problem
Qt 6.11 is out! See what's new in the release blog

QTextDocument HTML table problem

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 7.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imihajlov
    wrote on last edited by
    #1

    I'm trying to print a table using QPrinter and QTextDocument. I want a table with single-line borders, but I get weird result:
    !http://rain.ifmo.ru/~imihajlov/table.png(Table)!
    The HTML code is:
    @<table width="100%" cellspacing="0" cellpadding="2px">
    <tr>
    <th width="20%">Test</th>
    <th width="20%">Nominal</th>
    <th width="10%">Col. 1</th>
    <th width="10%">Col. 2</th>
    <th width="10%">Col. 3</th>
    <th width="10%">Col. 4</th>
    <th width="10%">Col. 5</th>
    <th width="10%">Col. 6</th>
    </tr>
    ........
    </table>@

    What should I do to make borders single-lined? border-collapse does not work.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      broadpeak
      wrote on last edited by
      #2

      Under Linux/Windows you get a print preview, try to see there the html table lines. If there is ok, problem is probably with your printer.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        imihajlov
        wrote on last edited by
        #3

        It's a screenshot from PDF. Real printing produces the same output. Even more, I have tested the same HTML code with QtCreator's form editor, it produces the same lines.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ObiWan
          wrote on last edited by
          #4

          As you can see "here":http://qt-project.org/doc/qt-4.8/richtext-html-subset.html border-collapse is not supported.

          I faced the same problem last week. But I couldn't figure out a solution.

          1 Reply Last reply
          1
          • I Offline
            I Offline
            imihajlov
            wrote on last edited by
            #5

            Now I'm using xhtml2pdf instead :)

            1 Reply Last reply
            0
            • O Offline
              O Offline
              ObiWan
              wrote on last edited by
              #6

              I searched once more the depths of the WEB and found a solution, that might interest you.

              @ QWebView web;
              web.setHtml(strHtml);
              QPrinter printer;
              web.print(&printer);
              @

              It works fine.

              1 Reply Last reply
              0
              • I Offline
                I Offline
                imihajlov
                wrote on last edited by
                #7

                It should, but QWebView is not acceptable for my task as a part of WebKit.

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved