PDA

View Full Version : Qwt Printing



giusepped
10th December 2008, 09:04
I copied the code from the bode example in my program.
No errors, anyway the result of the printing is wrong, because
1) the axis are not shown (the ticks are shown)
2) the content of the plot, not the box, is shifted down.

I put the code for completeness.


void OptimumPlot::printOut()
{
QString path = QDir::currentPath()+tr("/radiazione.ps");
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName(path);
printer.setCreator("Solar Calc");

printer.setOrientation(QPrinter::Portrait);
QPrintDialog dialog(&printer);
if ( dialog.exec() )
{
QwtPlotPrintFilter filter;
if ( printer.colorMode() == QPrinter::GrayScale )
{
int options = QwtPlotPrintFilter::PrintAll;
options &= ~QwtPlotPrintFilter::PrintBackground;
options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);
}

print(printer, filter);



}
}

giusepped
11th December 2008, 18:08
Nobody has the same problem or my question is too elementary?

giusepped
12th December 2008, 09:20
Some diagnostic.
I realized that if I delete this code


void OptimumPlot::alignScales()
{
// The code below shows how to align the scales to
// the canvas frame, but is also a good example demonstrating
// why the spreaded API needs polishing.

canvas()->setFrameStyle(QFrame::Box | QFrame::Plain );
canvas()->setLineWidth(1);

for ( int i = 0; i < QwtPlot::axisCnt; i++ )
{
QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(i);
if ( scaleWidget )
scaleWidget->setMargin(0);

QwtScaleDraw *scaleDraw = (QwtScaleDraw *)axisScaleDraw(i);
if ( scaleDraw )
scaleDraw->enableComponent(QwtAbstractScaleDraw::Backbone, false);
}
}


which was suggested by the "bode" example

all wors (the print is correct) but I could not get the scale aligned.
Any help?

giusepped
12th December 2008, 09:25
To be more precise, I get such picture: