Trouble to print with QPrintPreviewWidget
Hi friends,
I'm trying to print some pages from a QPrintPreviewWidget, to call QPrintDialog to set the range of pages want to print, is printed every page, not the range. What I'm doing wrong? Any suggestions?
Follow small code:
Report.h
Code:
{
Q_OBJECT
public:
QPrintPreviewWidget *printPreview;
private:
Ui::Report ui;
private slots:
void print();
};
#endif
Report.cpp
Code:
#include "Report.h"
{
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
this->showMaximized();
printer
->setOutputFormat
(QPrinter::NativeFormat);
printer
->setOrientation
(QPrinter::Portrait);
printer->setFullPage(true);
printPreview = new QPrintPreviewWidget(printer, this);
ui.gridLayout1->addWidget(printPreview);
connect(ui.ActPrint, SIGNAL(triggered()), this, SLOT(print()));
connect(printPreview,
SIGNAL(paintRequested
(QPrinter*)), widgetReport,
SLOT(Print
(QPrinter*)));
printPreview->fitInView();
printPreview->show();
}
void Report::print()
{
printDialog.setMinMax(1, printPreview->numPages());
if (printDialog.
exec() == QDialog::Accepted) {
qDebug() << printPreview->numPages(); // OK, its return 3 pages, but print all if range is one or two.
printPreview->print();
}
}
Thanks,
Marcelo E. Geyer
Re: Trouble to print with QPrintPreviewWidget
It's possible to a bug? Or write my class in a way that these controls will not work? Someone has worked with QPrintPreviewWidget?
Re: Trouble to print with QPrintPreviewWidget
Hi guys, Anybody to help?
Re: Trouble to print with QPrintPreviewWidget
You widgetReport::Print method should read out the the print range and paint accordingly.
Re: Trouble to print with QPrintPreviewWidget
I've got the same problem here. I use pyqt.
Do you have solution already?
Re: Trouble to print with QPrintPreviewWidget
I've got a similar problem... Qt is too raw to use it in serious projects :mad:
I use .Net and I have never had any problems with printing (and print preview too) text and graphic. Printing is very important for my projects. I tried to convert one of my projects to Qt, but some things are impossible with Qt and some things are not documented as they should be.