Python Pyqt QtGui.QLineEdit.clear()
<p>I tried to set some strings by using QtGui.QLineEdit.setText() at the end of program and clear the strings using QtGui.QLineEdit.clear() at the beginning of the program. However, it never clears the strings. All I want to do is to clear the content at the beginning of the program to indicate it is running and at the end of the program to set the values and status of the program. Is there any suggestion or other way to fulfill this feature? Thank you very much.</p>

<p>Below is my code:(I omitted some other unrelated definitions and functions)</p>

<pre><code>def __init__(self):
    self.left = QtGui.QFrame()
    self.read_back_B0_to_B39 = QtGui.QTextEdit(self.left)
    self.first_read_Value_error = QtGui.QLineEdit(self.left)
    self.B0_B39_match = QtGui.QLineEdit(self.left)

def first_burn_margin_read(self):
    # try to clear the content
    self.first_read_Value_error.clear()
    self.read_back_B0_to_B39.clear()
    self.B0_B39_match.clear()

    # E3646 power supply setup
    power_channel = 1; power_range = 'LOW'; power_voltage = 3.3; power_current = 0.3
    self.power1_setup(power_channel, power_range, power_voltage, power_current)
    self.power1_on_off(False)
    self.power1_on_off(True)

    # E3631 power supply setup
    power_channel = 2; power_voltage = 7; power_current = 0.3
    self.power2_setup(power_channel, power_voltage, power_current)
    self.power2_on_off(False)
    self.power2_on_off(True)

    # 81130A setup
    fun_channel = 1; fun_frequency = 100; fun_duty_cycle = 50; fun_vlow = 0; fun_vhigh = 0.8
    self.fun_setup(fun_channel, fun_frequency, fun_duty_cycle, fun_vlow, fun_vhigh)
    self.fun_on_off(fun_channel, 1)
    time.sleep(1)        
    value = self.Byte0_to_Byte39.toPlainText()
    write_value = []*40
    for i in range(0,40):
        hex_express = str(value[5*i:5*i+4])
        hex_int = int(hex_express, 16)
        write_value.append(hex_int)
    self.i2c_write(128, write_value)
    time.sleep(2)
    try:
        burn_result = self.i2c_read(128, 40)
        self.first_read_Value_error.setText('No')
        if write_value[1:] == burn_result:
            B46 = int(str(self.B46_OTP_start_address_1.text()), 16)
            B47 = int(str(self.B47_OTP_stop_address_1.text()), 16)
            B48 = int(str(self.B48_Ram_burn_start_address_1.text()), 16)
            burn_registers = [B46, B47, B48]
            self.i2c_write(174, burn_registers)
            time.sleep(0.1)
            # # Burn OTP
            self.i2c_write(173, [0x8C])
            time.sleep(0.5)
            self.i2c_write(173, [0x0C])
            time.sleep(0.5)
            # Margin 1 read
            self.i2c_write(128, [0x00]*40)
            time.sleep(0.5)
            self.i2c_write(177, [0x00])
            time.sleep(0.1)
            self.i2c_write(173, [0x4C])
            time.sleep(0.1)
            self.i2c_write(173, [0x0C])
            time.sleep(1)
            margin_read = self.i2c_read(128, 40)
            row1 = ''
            row2 = ''
            row3 = ''
            row4 = ''
            for i in range(0,10):
                row1 += str(hex(margin_read[i])) + ' '
                row2 += str(hex(margin_read[i+10])) + ' '
                row3 += str(hex(margin_read[i+20])) + ' '
                row4 += str(hex(margin_read[i+30])) + ' '
            read_back = """%s
            %s
            %s
            %s
            """ % (row1, row2, row3, row4)
            self.read_back_B0_to_B39.setText(read_back)
            if write_value[1:] != margin_read:
                self.log.warn('The burning is not correct. Please check the setup and do it again.')
                self.B0_B39_match.setText('It is not matched.')
            else:
                self.log.info('1st pass burn and margin 1 read are successful, please go on.')
                self.B0_B39_match.setText('It is matched.')
        else:
            self.log.warn('The burning is not correct. Please check the setup and do it again.')
    except ValueError:
        self.first_read_Value_error.setText('Yes')
</code></pre>