[PyQt] Missing QPageSize enum in vars(QPrinter) ?

Phil Thompson phil at riverbankcomputing.com
Sat Oct 12 11:56:00 BST 2013


On Thu, 10 Oct 2013 09:43:10 -0400, lloyd konneker <bootch at nc.rr.com>
wrote:
> This code worked in PyQt4 and Qt4 to get a dictionary of paper size
names:
> 
> paperSizeNames = {}
> print(vars(QPrinter))
> for key, value in vars(QPrinter).items():  # Python2 iteritems():
>    if isinstance(value, QPrinter.PageSize):
>      print(key, value)
>      paperSizeNames[value] = key
> 
> It no longer works in PyQt5 and Qt5.0.1.  But other enum values appear 
> to be in vars(QPrinter)?  Is missing QPageSize enum a bug of omission in

> PyQt5?
> 
> This is NOT too important, since Qt 5.1 offers 
> QPrinter.supportedSizesWithNames(), which more or less does the same 
> thing (returns a map from names to QSizeF, which I suppose could be 
> mapped to QPageSize enum values i.e. encodings.)
> 
> Is there another way to get the names of Qt enum values?

In Qt5 the PageSize enum is defined in the QPagedPaintDevice class.

Phil


More information about the PyQt mailing list