[PyQt] Can't QLineEdit.isModified with QCompleter?

Ryan Hanson crossrocker at gmail.com
Mon Mar 25 13:41:56 GMT 2013


I am writing a program to interact with a database and one of my pages I
allow the users to modify the values using QlineEdits. They when the user
saves I check isModified so I know which values to save. It works as
expected on most of the lines but a have one that uses a QCompleter and
isModified returns false if the user picks off the list.

Is there a way around this? If not any suggestions on how I should check if
the item has been modified?

I have some sample code showing my problem.

<code>
import sys
from PyQt4 import QtCore, QtGui

class Ui_Form(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setObjectName("Form")
        self.resize(138, 73)
        self.verticalLayout = QtGui.QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.lineEdit = QtGui.QLineEdit(self)
        self.lineEdit.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.lineEdit)
        self.pushButton = QtGui.QPushButton(self)
        self.pushButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.pushButton)
        self.comp = QtGui.QCompleter(['1','2','3','4','5'])
        self.lineEdit.setCompleter(self.comp)
        self.pushButton.clicked.connect(self.modified)
        self.lineEdit.textChanged.connect(self.textMod)

    def modified(self):
        print self.lineEdit.isModified()

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    myapp = Ui_Form()
    myapp.show()
    sys.exit(app.exec_())
</code>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130325/3437f859/attachment.html>


More information about the PyQt mailing list