Good afternoon! Recently I was trying to print a Web page from QWebView and
ran into a pretty weird problem. It is the following: I can print my
QWebView perfectly when setting the QPrinter's output format to PDF or
PostScript. But when I try to print to a normal printer, however, it gives
me the correct number of pages, only that the pages are all blank. I tried
to do this with a virtual PDF printer in Windows, a normal printer (it had
ink, btw =), tried to choose the "print to file" option on Windows, and the
results were all the same. The other thing that puzzles me even more is that
if I replace the QWebView with a QTextEdit, everything works perfectly with
all kinds of printers. So I hope that someone can give me a little help, I
would appreciate it very much. Thank you!

P.S. Here is the code that I use for testing that issue (I copied it from
http://orangepalantir.org/topicspace/index.php?idnum=31):

from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtWebKit as QtWebKit

import sys

class htmlViewer(QtWebKit.QWebView):
    def __init__(self,url, parent=None):
        QtWebKit.QWebView.__init__(self,parent)
        self.setUrl(QUrl(url))
        self.preview = QPrintPreviewDialog()
        self.connect(self.preview,SIGNAL("paintRequested (QPrinter
*)"),SLOT("print (QPrinter *)"))
        self.connect(self,SIGNAL("loadFinished (bool)"),self.execpreview)
    def execpreview(self,arg):
        print arg
        self.preview.exec_()

if __name__=="__main__":
    app = QApplication(sys.argv)

    myurl = "http://www.google.com";
    widget = htmlViewer(myurl)
    widget.show()

    sys.exit(app.exec_())
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to