Results 1 to 2 of 2

Thread: Newbie: Pdf doesnt print correctly

  1. #1
    Join Date
    Jan 2012
    Posts
    10
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Newbie: Pdf doesnt print correctly

    Hi,

    I am starting out with qwt and my intentions are to create a pdf of a pot without displaying any graphics. Unfortunately, the following code produces a pdf (see file.pdf) without axis and points. Please could somebody point out where i am going wrong

    Qt Code:
    1. QwtPlot *plot=new (QwtPlot);
    2.  
    3. plot->setTitle( "Result" );
    4. plot->setCanvasBackground( Qt::white );
    5. plot->setAxisScale(QwtPlot::yLeft, 0.0, 10.0 );
    6. plot->insertLegend( new QwtLegend() );
    7.  
    8. QwtPlotGrid *grid = new QwtPlotGrid();
    9. grid->attach(plot);
    10.  
    11. QwtPlotCurve *curve = new QwtPlotCurve();
    12. curve->setTitle("Curve");
    13. curve->setPen( QPen( Qt::blue, 4 ) ),
    14. curve->setRenderHint( QwtPlotItem::RenderAntialiased, false );
    15.  
    16. QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
    17. QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
    18. curve->setSymbol( symbol );
    19.  
    20. QPolygonF points;
    21. points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
    22. << QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
    23. << QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
    24. curve->setSamples( points );
    25.  
    26. curve->attach( plot );
    27.  
    28. plot->resize(600,400);
    29.  
    30. QwtPlotRenderer renderer;
    31. renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
    32. renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
    33. renderer.renderDocument(plot, "file.pdf", QSizeF(300, 200), 85);
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Newbie: Pdf doesnt print correctly

    You have to do a replot before rendering your pdf.

    Uwe

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

    rajil.s (24th January 2012)

Similar Threads

  1. QPropertyAnimation doesnt do anything
    By superpacko in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2011, 16:04
  2. QWT doesnt show any windows
    By Cal in forum Qwt
    Replies: 5
    Last Post: 30th June 2009, 17:05
  3. Cancelling Long-running Print/Print Preview
    By ChrisW67 in forum Newbie
    Replies: 4
    Last Post: 16th June 2009, 23:05
  4. connect doesnt work
    By john_god in forum Newbie
    Replies: 4
    Last Post: 23rd November 2008, 09:36
  5. How come this doesnt work?
    By ShaChris23 in forum Newbie
    Replies: 8
    Last Post: 16th June 2007, 04:43

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.