Results 1 to 2 of 2

Thread: qgraphicsview can't preview by QPrintPreviewDialog

  1. #1
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation qgraphicsview can't preview by QPrintPreviewDialog

    void MainWindow:: openPrintPreviewDialog()
    {
    QPrinter printer(QPrinter::HighResolution);
    printer.setPaperSize(QPrinter::A4);

    QPainter painter(&printer);
    GetCurWindow()->getView()->render(&painter);
    QPrintPreviewDialog preview(&printer,this);
    connect(&preview, SIGNAL(paintRequested(QPrinter *)),this,SLOT(printPreView(QPrinter *)));
    preview.exec();
    }

    void MainWindow:: printPreView( QPrinter * printer)
    {
    ///view
    GraphicsView* currView = GetCurWindow()->getView();
    QPainter painter(printer);
    currView->render(&painter );
    }

    why graphicsview can preview by qprintpreviewdialog ?

  2. #2
    Join Date
    Jan 2011
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qgraphicsview can't preview by QPrintPreviewDialog

    instead of rendering the QGraphicsView, try rendering its viewport, since the viewport contains the content you're interested in.

Similar Threads

  1. Pratical example of QPrintPreviewDialog
    By vcp in forum Qt Programming
    Replies: 5
    Last Post: 24th July 2012, 16:24
  2. QGraphicsView : create a "quick preview" ?
    By pl01 in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2011, 12:51
  3. QPrintPreviewDialog.
    By cydside in forum Qt Programming
    Replies: 2
    Last Post: 19th June 2009, 17:31
  4. QPrintPreviewDialog icons
    By quipu5 in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2009, 13:36
  5. 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.