QObject::startTimer: QTimer can only be used with threads started with QThread?
<p>I have given the model a parent, but it still shows error message when exiting, what was wrong in the following code</p>

<pre><code>#!/usr/bin/env python2
import os
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic

import re

CODE = 'xxx'


class MyWindow(QDialog):

    def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent)
        layout = QVBoxLayout(self)
        textedit = QTextEdit(self)

        textedit.setPlainText(CODE)
        layout.addWidget(textedit)
        self.setLayout(layout)

        self.resize(640, 280)

        self.lineedit = QLineEdit(self)
        self.lineedit.setGeometry(200, 12, 200, 32)

        self.completer = QCompleter(self)

        model = QStringListModel(self)
        model.setStringList(['1','2','3','4'])
        self.completer.setModel(model)
        self.lineedit.setCompleter(self.completer)

def main():

    app = QApplication(sys.argv)
    win = MyWindow()
    win.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
</code></pre>

<p>The above code errors out when exiting.</p>

<pre><code>$ python2.7 ./ask_keep_completer0.py
QObject::startTimer: QTimer can only be used with threads started with QThread
Segmentation fault (core dumped)
</code></pre>

<p><img src="http://i.imgur.com/WfevhJ3.gif" alt="img"></p>

<p>after adding this call, it doesn't error out anymore</p>

<pre><code>self.setAttribute(Qt.WA_DeleteOnClose)
</code></pre>

python qt pyqt qcompleter