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. QPrintPreviewDialog doesn't display html doc correctly

QPrintPreviewDialog doesn't display html doc correctly

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 401 Views
  • 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.
  • W Offline
    W Offline
    WhatIf
    wrote on last edited by WhatIf
    #1

    Hi,

    I want to print some info from HTML table but the info doesn't display correctly in print preview dialog. The headers don't display in one line, I tried to chage the size property many times buts still. And there are missing letters, Jill displays only J l and Smith displays as Sm th.

    Here is an snapshot of the print preview dialog:

    https://s11.postimg.org/mg6hy4tar/print_preview.jpg

    and the HTML code is:

    doc = "<!DOCTYPE html>"
                "<html>"
    
    
    
                "<body>"
    "<font size=\"72\">"
                "<table style=\"width:100%\">"
    
                  "<tr>"
                    "<th>Firstname</th>"
                    "<th>Lastname</th>"
                    "<th>Age</th>"
                  "</tr>"
                  "<tr>"
                    "<td>Jill</td>"
                    "<td>Smith</td>"
                    "<td>50</td>"
                  "</tr>"
                  "<tr>"
                    "<td>Eve</td>"
                    "<td>Jackson</td>"
                    "<td>94</td>"
                  "</tr>"
                  "<tr>"
                    "<td>John</td>"
                    "<td>Doe</td>"
                    "<td>80</td>"
                  "</tr>"
    
                "</table>"
    "</font>"
                "</body>"
                "</html>";
    

    I also tried addig

                "<head>"
                "<style>"
                "table, th, td {"
                    "font-size:small;"
                "}"
                "th, td {"
                    "padding: 5px;"
                "}"
                "th {"
                    "text-align: left;"
                "}"
                "</style>"
                "</head>"
    

    I got only 3 letters per page.

        QTextDocument  *document = new QTextDocument ;
        document->setHtml(doc);
        document->print(p);
    
    1 Reply Last reply
    0

    • Login

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