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. Best way to display and print a form document
Forum Updated to NodeBB v4.3 + New Features

Best way to display and print a form document

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 254 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.
  • Q Offline
    Q Offline
    QuentinP
    wrote on last edited by QuentinP
    #1

    Hello,
    I need to display/print forms documents.
    I used to do it by generating HTML code in a file, then open the file with a browser (firefox for example) to print it.
    This forms documents are generated by my app, and what I want to do now is to avoid the used of the browser plus having an in app display of the form document.
    I saw that Qt allow to parse HTML code but it do not support some features I use. (<textarea> and special symbols like &#9744)

    Here is a simple HTML code generated by my app :

    <!DOCTYPE html>
     <html>
     <body>
    
    <center>
        <h2>
            Question and Answer n°1
        </h2>
    </center>
    
    <p>
        Question 1 : Is this a nice question ? <br>
        Yes it is &#9744 <br>
        Nope &#9744 <br>
    </p>
    
    <p>
    	Question 2 : What would you do with 2 tons of toilet paper : <br>
        <textarea rows="3" cols="91"> </textarea>
    </p>
    
    <p>
        Question 3 : Connect each programming langage to your skill with it : <br>
        C++ &#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Good <br>
        Java &#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Medium <br>
    	Php	&#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Bad <br>
    </p>
    
        </body>
        </html>
    

    And it gives the following output :

    out.png

    I m kinda new to Qt but I m sure there is an easy way to display and print that kind of document.
    I have take a look at the QTextDocument but how could I draw the <textarea> rect in it ?
    About the QPainter, I did not managed to find the size on screen of a drawn text (in order to draw something right after it).
    I m aware of the QPrinter class, what I m looking for is more a printable way to display documents like in the picture above.
    If someone could light me with his knowledge about the best way to do this, it would be very helpful !
    Thanks for your precious time.
    Quentin P

    JonBJ 1 Reply Last reply
    0
    • Q QuentinP

      Hello,
      I need to display/print forms documents.
      I used to do it by generating HTML code in a file, then open the file with a browser (firefox for example) to print it.
      This forms documents are generated by my app, and what I want to do now is to avoid the used of the browser plus having an in app display of the form document.
      I saw that Qt allow to parse HTML code but it do not support some features I use. (<textarea> and special symbols like &#9744)

      Here is a simple HTML code generated by my app :

      <!DOCTYPE html>
       <html>
       <body>
      
      <center>
          <h2>
              Question and Answer n°1
          </h2>
      </center>
      
      <p>
          Question 1 : Is this a nice question ? <br>
          Yes it is &#9744 <br>
          Nope &#9744 <br>
      </p>
      
      <p>
      	Question 2 : What would you do with 2 tons of toilet paper : <br>
          <textarea rows="3" cols="91"> </textarea>
      </p>
      
      <p>
          Question 3 : Connect each programming langage to your skill with it : <br>
          C++ &#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Good <br>
          Java &#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Medium <br>
      	Php	&#9899 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#9899 Bad <br>
      </p>
      
          </body>
          </html>
      

      And it gives the following output :

      out.png

      I m kinda new to Qt but I m sure there is an easy way to display and print that kind of document.
      I have take a look at the QTextDocument but how could I draw the <textarea> rect in it ?
      About the QPainter, I did not managed to find the size on screen of a drawn text (in order to draw something right after it).
      I m aware of the QPrinter class, what I m looking for is more a printable way to display documents like in the picture above.
      If someone could light me with his knowledge about the best way to do this, it would be very helpful !
      Thanks for your precious time.
      Quentin P

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @QuentinP
      If I understand you to be saying you do want an in-app display of the page, plus being able to send to printer, and you would have done it via an external HTML file, are you aware of Qt's QWebEnginePage, which is a Chromium offering?

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QuentinP
        wrote on last edited by
        #3

        Hum that's might be what I m looking for ! Thanks a lot mate !

        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