Q_ENUMS in PyQt4

I would like to use the Qt enumeration facilities. I saw in the documentation of the QtCore module there are Q_ENUMS macros, but I do not know the information on how to use it.

+4
source share
1 answer

In python (and PyQt), the way to create an enumeration is as follows:

class MyEnum(object): One = 1 Two = 2 Three = 3 

If you need more functionality than this, please give more details on what you are trying to do.

EDIT

Looking at the documentation for QAbstractSocket.stateChanged I see that this refers to "Creating Custom Qt Types". I am not aware of the need to register metatypes in PyQt4, so all you need to do to use this signal is connect it to the appropriate handler:

 class Socket(QTcpSocket): def __init__(self): QTcpSocket.__init__(self) self.stateChanged.connect(self.handleStateChanged) def handleStateChanged(self, state): print state 
+4
source

All Articles