Results 1 to 8 of 8

Thread: Printing the content

  1. #1
    Join Date
    Apr 2007
    Location
    Bangalore,India
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Printing the content

    Hello All,

    I want to print the content of the QTextEdit ,but the problem is
    I have a rich text in QTextEdit when I try to print the text of this QTextEdit
    It prints the HTML tags along with the content,

    I don't want to print the tags, nor as a plain text...
    But as a richText with the same font , size ,Color.... as seen in the QTextEdit .

    Thanks,
    Veda

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing the content

    How r u printing the data? Did you look some of the examples given in assistant.
    I could find the following.

    Qt Code:
    1. void MainWindow::print()
    2. {
    3. QTextDocument *document = textEdit->document();
    4. QPrinter printer;
    5.  
    6. QPrintDialog *dlg = new QPrintDialog(&printer, this);
    7. if (dlg->exec() != QDialog::Accepted)
    8. return;
    9.  
    10. document->print(&printer);
    11.  
    12. statusBar()->showMessage(tr("Ready"), 2000);
    13. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2007
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Printing the content

    I'm experiencing the same problem. I have a QString that has an HTML table, but when I construct a QTextDocument and call print on it, I get a printout of the HTML, not of the table. What am I doing wrong?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Printing the content

    Did you tell the document that it contains rich text? For instance by using QTextDocument::setHtml.

  5. The following user says thank you to wysota for this useful post:

    joshlareau (25th September 2007)

  6. #5
    Join Date
    Dec 2006
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing the content

    I am having the same problem which should print html content on embedded machine.

    My qt version is 3.3.4. It doesn't have QTextDocument, QPrintDialog.

    Please tell me how to print

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Printing the content

    There is no easy way of doing that in Qt 3.

  8. #7
    Join Date
    Apr 2007
    Location
    Bangalore,India
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing the content

    Try using QSimpleRichText::draw function
    Veda

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Printing the content

    Just remember it won't divide the text into pages. You have to draw each page separately.

Similar Threads

  1. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  2. Printing a Qstring
    By harakiri in forum Newbie
    Replies: 6
    Last Post: 24th June 2007, 12:52
  3. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  4. Re: Printing in Qt
    By Jimmy2775 in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 23:00
  5. Replies: 0
    Last Post: 28th June 2006, 20:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.