Is it possible to convert a qt enum value to its key?
For example I’d like to get to get ‘A4’ from QPrinter class knowing that QPrinter.A4 = 0
Thank you in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Usually, you can do this using the
QMetaObject:However it appears that
QPrinterhasn’t exposed a meta object, so you’ll have to do it by walkingQPrinter‘s attributes in Python (fortunately PyQt enums are subclasses ofint, so can be identified byisinstance):