开发者

Python Qt: Qprinter not defined

I am trying to put the printer to run the output from an html document.

Here is a small function to do that:

def callPrinterHtml(self,document):
    self.printer = QPrinter()
    self.printer.setPageSize(QPrinter.Letter)

    dialog = QPrintDialog(self.printer, self)
    if dialog.exec_():
     开发者_开发百科   document.print_(self.printer)

However the message pops up:

self.printer = QPrinter()
NameError: global name 'QPrinter' is not defined

The printer definition is clearly inside the function. So, what am I missing here?

All comments and suggestions are highly appreciated.


  1. Did you import the module that contains QPrinter? using an import directive?

  2. Is the module containing QPrinter in your python path?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜