QPrintPreviewDialog doesn't display html doc correctly



  • 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);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.