Results 1 to 4 of 4

Thread: How can I export my user interface as pdf

  1. #1
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How can I export my user interface as pdf

    I want to export my qt window as pdf. How can I do that?. I found this link http://qt-project.org/wiki/Exporting_a_document_to_PDF. but this is for text I think. I want export everything what I saw on screen. How can I do that?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How can I export my user interface as pdf

    Try calling your widget's render() method with a QPrinter configured for PDF output as the paint device.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    256
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can I export my user interface as pdf

    No, it is not. QTextDocument is a "full sized" document supporting all kinds of formatting, including embedded images, tables and other bells and whistles. So you can create a document which includes pictures of your API along with an accompanying text and then print it in a file as a PDF theoretically. But I think this is a rather challenging decision: you need to write a "full sized" document editor for it.

    IMO, there are far simpler methods. Create the images using some kind of a screen grabber then use a ready-to-use document editor that can output to a PDF (Libre Office, Open Office (starting from version 3 I think), even micro$oft office. Create a document and output to a PDF. Done.

  4. #4
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can I export my user interface as pdf

    Thanks. I solved my problem

    Qt Code:
    1. QPixmap pixmap;
    2. pixmap=QPixmap::grabWindow(ui->widget->winId());
    3.  
    4. QPrinter printer;
    5. printer.setOrientation(QPrinter::Landscape);
    6. printer.setOutputFormat(QPrinter::PdfFormat);
    7.  
    8. printer.setOutputFileName(QApplication::applicationDirPath()+QDir::separator()+"file");
    9.  
    10. QPainter painter(&printer);
    11. QRect rect=painter.viewport();
    12. QSize size=pixmap.size();
    13.  
    14. size.scale(rect.size(), Qt::KeepAspectRatio);
    15. painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
    16. painter.setWindow(pixmap.rect());
    17.  
    18. painter.drawPixmap(0,0,100,100,pixmap);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. User Interface Designer
    By MartinUI in forum Resumes
    Replies: 0
    Last Post: 15th March 2013, 12:47
  2. how to change value of spinbox by user interface?
    By kinjalp in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2012, 13:25
  3. Regarding Database Display through user interface
    By Tavit in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2008, 10:32
  4. User Interface with QTableView
    By Brandybuck in forum Qt Programming
    Replies: 1
    Last Post: 22nd March 2006, 23:24

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.