'QLineEdit' object has no attribute 'delete' in Plugin QGIS Dufour

309 Views Asked by At

When I tried to open text file in text browser I got this error

def cari(self, event=None):
    #open dialog
    filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')

    if filename:
        self.ui.lineFile.delete(0, END)
        self.ui.lineFile.insert(END, filename)

    #call isi data
    self.isiDataFile(filename)

def isiDataFile(self, nmfile):
    #open with read mode
    teksFile = open(nmfile, 'r').read()

    self.ui.textFile.delete('1.0', END)
    self.ui.textFile.insert('1.0', teksFile)

Error:

Traceback (most recent call last):
  File "C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py", line 44, in cari
    self.ui.lineFile.delete(0, END)

 'QLineEdit' object has no attribute 'delete'

Can someone help me?

1

There are 1 best solutions below

0
On

If you see the docs, QLineEdit (self.ui.lineFile in your code) doesn't have delete method, but has a del_ method and a backspace method. You might want to use one of these.