You upload some png file to fileName. Then you set QPrinter to print in this png file using printer.setOutputFileName(fileName); . I suppose this is wrong, probably it should be some other PDF file.
I'm not sure if I understand what you are trying to do? How to print image file using QPrinter? To pdf file? Why are you trying to use QWebView? You can use QImage to load an image file, and then draw a QPainter on a QPrinter.
#include <QtGui> #include <QtCore> int main(int argc, char** argv) { QApplication app(argc, argv); QString fileName = QFileDialog::getOpenFileName(0,"Open File",QString(),"PNG File(*.png)"); QPrinter printer; QPrintDialog *dlg = new QPrintDialog(&printer,0); if(dlg->exec() == QDialog::Accepted) { QImage img(fileName); QPainter painter(&printer); painter.drawImage(QPoint(0,0),img); painter.end(); } delete dlg; QTimer::singleShot(1, &app, SLOT(quit())); app.exec(); return 0; }
Some of your problems may coincide with your other question .
LukasT Nov 29 '11 at 13:06 2011-11-29 13:06
source share