Results 1 to 4 of 4

Thread: How to save file as ".pdf" from QPrinter

  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default How to save file as ".pdf" from QPrinter

    Hi, all,
    I want to save file as "outpuf.pdf" that is previewed via QPrintPreviewWidget. according to Qt's assistant, void QPrinter::setOutputToFile ( bool enable ) can be used, however, when i called this function, error C2039: 'setOutputToFile' : is not a member of 'QPrinter' occurs.

    Why?

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to save file as ".pdf" from QPrinter

    You should use
    Qt Code:
    1. yourPrinter.setOutputFormat (QPrinter::PdfFormat);
    To copy to clipboard, switch view to plain text mode 
    I'm a rebel in the S.D.G.

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

    nifei (5th March 2009)

  4. #3
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: How to save file as ".pdf" from QPrinter

    'setOutputToFile' is a member of of the Qt 3 support layer. You should use following:

    printer.setOutputFormat(QPrinter::PdfFormat);

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

    nifei (5th March 2009)

  6. #4
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Red face Re: How to save file as ".pdf" from QPrinter

    I supposed that "out.pdf" will be created automatically when the slot print(QPrinter*) is invoked by QPrintPreviewWidget:aintRequested(QPrinter*), but i was wrong. I just called print(QPrinter*) and the file is created.

Similar Threads

  1. How to save file with QFileDialog
    By pnikolov in forum Qt Programming
    Replies: 11
    Last Post: 1st June 2012, 10:23
  2. How set default file to save in QFileDialog
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 12:09
  3. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  4. Restrict user from entering space in Save As File Name
    By jyoti kumar in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 12:47
  5. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21

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.