Why I get “QTimer can only be used with threads started with QThread” messages if I have no QTimer in my code?

前端 未结 3 1783
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 17:40

When (and only when) I quit my application, these (and only these) repeated message appear on the command prompt:

QObject::startTimer: QTimer can only be used wi         


        
3条回答
  •  时光取名叫无心
    2021-02-20 18:03

    I've had similar problems in the past.

    The QFileSystemModeldocumentation page says the following:

    QFileSystemModel.__init__ (self, QObject parent = None)

    The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

    Constructs a file system model with the given parent.

    If you don't pass a parent argument then the Python garbage collector can delete the object at the wrong time and as a side effect raise the error you mention. My advise is to make sure that your objects have a proper parent. I think it should fix the problem.

    PS: I haven't checked the docs for every class you use. Maybe QFileSystemModel is not the only class on which this thing happens.

提交回复
热议问题