'QLineEdit'对象在Plugin QGIS Dufour中没有属性'delete'

时间:2013-12-02 03:39:47

标签: python qgis

当我尝试在文本浏览器中打开文本文件时出现此错误

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)

错误:

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'

有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

如果您看到docsQLineEdit(代码中为self.ui.lineFile)没有delete方法,但有del_方法和backspace方法。您可能想要使用其中一个。