开发者

Q_ENUMS in PyQt4

开发者 https://www.devze.com 2023-04-13 01:52 出处:网络
I would like to u开发者_StackOverflow社区se facilities of enumeration of Qt. I saw in documentation of the module of QtCore there is a macros of Q_ENUMS, but I do not know and information how to use h

I would like to u开发者_StackOverflow社区se facilities of enumeration of Qt. I saw in documentation of the module of QtCore there is a macros of Q_ENUMS, but I do not know and information how to use him.


In python (and PyQt), the way to create an enum is like this:

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

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

EDIT

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

class Socket(QTcpSocket):
    def __init__(self):
        QTcpSocket.__init__(self)
        self.stateChanged.connect(self.handleStateChanged)

    def handleStateChanged(self, state):
        print state
0

精彩评论

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