Results 1 to 4 of 4

Thread: Re: Printing in Qt

  1. #1
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Printing in Qt

    Does anyone know of any good introductory material regarding printing in Qt? I've seen some pretty good posts about more specific topics in Qt printing here in the forums, but I'm really new to the topic and was hoping to find some basic examples so I can get a sense of what's involved.

    From what I've read so far, it seems as though I need to generate a QTextDocument and then paint it using a QPrinter object, but I'm not really clear on the details of the process yet.

    Thanks

    Jimmy

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Printing in Qt

    Printing a QTextDocument is something as simple as this:
    Qt Code:
    1. QTextDocument* document = textEdit->document();
    2. QPrinter printer;
    3.  
    4. QPrintDialog* dialog = new QPrintDialog(&printer, this);
    5. if (dialog->exec() == QDialog::Accepted)
    6. {
    7. document->print(&printer);
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    Jimmy2775 (12th July 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Printing in Qt

    That certainly simplifies things a lot, at least on the printing end. Now I just have to figure out how to generate a QTextDocument...

    Thanks jpn

  5. #4
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Printing in Qt

    I want to use Qt to generate reports. I've had a look at how printing works in Qt (thanks again jpn) and the idea of generating a QTextDocument based on my data seems pretty straightforward. The only issue I'm having is with the concept of page headers and footers. I would like to have a header and footer on each page, and I imagine there is some way to do this once the page size has been determined by the QPrintDialog. Has anyone had any kind of experience with this?

    -- Note that this post is appearing at the top of the thread due to date issues with the server. It should appear just after the post where I thanked jpn (12th July 2006, 12:02)
    Last edited by jacek; 13th July 2006 at 11:21. Reason: post date has been changed to restore order of messages in the thread

Similar Threads

  1. Replies: 0
    Last Post: 28th June 2006, 20:49
  2. [QT4] Printing a dialog
    By KShots in forum Qt Programming
    Replies: 13
    Last Post: 28th April 2006, 13:46
  3. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  4. Qt Printing on .ps
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2006, 23:22
  5. Printing Copyright Cicle C from QString
    By jakamph in forum Newbie
    Replies: 7
    Last Post: 13th February 2006, 22:04

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.