开发者

PyQt4 - Cannot use QObject's functions in class inherited from QGraphicsItem (which inherits QObject)

I wrote python code looking something like this:

class Regularblock(QGraphicsItem):
    def __init__(self):
        super(QGraphicsItem).__init__()
        self.startTimer(100)
    def timerEvent(self, QTimerEvent):
开发者_如何转开发        do_something

But when I try to initialize an instance of Regularblock, I get "AttributeError: 'Regularblock' object has no attribute 'startTimer'". Why does this happen? Am I missing something big?


Short answer: I think QGraphicsItem is not actually a subclass of QObject. Have a look here; it is not listed as one of the QOject's direct subclasses. I'm not 100% sure, but perhaps you should be using QGraphicsObject ?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜