Results 1 to 6 of 6

Thread: Pratical example of QPrintPreviewDialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pratical example of QPrintPreviewDialog

    Quote Originally Posted by vcp View Post
    Hi all,

    I'm needing of the pratical example of how use the class QPrintPreviewDialog. I did not find no documentation about this. I need a pratical example.
    I think that the Throlltec's must update the samples programs.

    this piece of code is from
    http://fop-miniscribus.googlecode.co...o/textedit.cpp

    its only a qt4.4.1/demos/textedit + OpenOffice odt reader

    to get full svn code open:
    http://www.qt-apps.org/content/show....?content=80650

    Qt Code:
    1. void TextEdit::filePrintPreview()
    2. {
    3. #ifndef QT_NO_PRINTER
    4. QPrinter printer(QPrinter::HighResolution);
    5. QPrintPreviewDialog preview(&printer, this);
    6. preview.setWindowFlags ( Qt::Window );
    7. connect(&preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printPreview(QPrinter *)));
    8. preview.exec();
    9. #endif
    10. }
    11.  
    12. void TextEdit::printPreview(QPrinter *printer)
    13. {
    14. #ifndef QT_NO_PRINTER
    15. textEdit->print(printer);
    16. #endif
    17. }
    To copy to clipboard, switch view to plain text mode 

    IMO: if you like to build static QPrintPreviewDialog append his icon

  2. #2
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Thanks
    5
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pratical example of QPrintPreviewDialog

    Thanks to patrik08 by your help.

    I think that the objective of this forum be help the persons and not depreciate the questions, by more samples that they be.

  3. #3
    Join Date
    Apr 2010
    Posts
    17
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Pratical example of QPrintPreviewDialog

    hi.
    why the printer in this function:
    Qt Code:
    1. void dlg_account::on_btn_print_clicked()
    2. {
    3. QPrinter printer(QPrinter::HighResolution);
    4. printer.setFullPage( true );
    5. QPrintPreviewDialog preview(&printer, this);
    6. preview.setWindowFlags ( Qt::Window );
    7. connect(&preview, SIGNAL(paintRequested(QPrinter* )), SLOT(print(QPrinter* )));
    8. preview.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    isnt recognised in the:
    Qt Code:
    1. void dlg_account::print( QPrinter* printer)
    2. {
    3. QPainter *painter=new QPainter(printer);
    4. QRect paper = printer->pageRect();
    5. painter->setPen(Qt::black);
    6. painter->setFont(QFont("Sans",14,0,0));
    7. painter->drawText(QRect(0,0,100,100),Qt::AlignLeft||Qt::AlignTop,"page1");
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt 4.4.0 Problem with QPrintPreviewDialog
    By ad5xj in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2008, 14:01

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
  •  
Qt is a trademark of The Qt Company.