QLineEdit is not updated with setText

I have a program with two windows, main and settings.
When I run setText in QLineEdit in the settings.py file, the new line is not in the GUI, and I can see the line before the setText code.
When I put the same code in the settingsUI file created from Qt Designer, it works. But in settings.py not.
A settings file is a file containing the SettingsWindow class, and I can put real python code into it.
The UI settings file is a file containing a graphical interface, I generated it using pyuic4 (or pyuic5).
This code works in the settings file:

  self.browse_file.setText("safa")

But do not work in the settings file.

- UPDATE -

import sys
from PyQt4 import QtCore, QtGui
from settingsui import Ui_Dialog
class SettingsWindow(QtGui.QDialog, Ui_Dialog):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        Ui_Dialog.__init__(self)
        self.setupUi(self)
        self.lineEdit.setText("safa")
        print self.lineEdit.text()

: self.lineEdit.setText("safa") QLineEdit.
print self.lineEdit.text() "safa"

+4
2

mainwind.py.

:

    def buttonclicked(self):
        Dialog = QtGui.QDialog()
        u = settings.SettingsWindow()
        u.setupUi(Dialog)
        Dialog.exec_()

, , , . ( u) setText(), , .

:

    def buttonclicked(self):
        dialog = settings.SettingsWindow()
        dialog.exec_()

SettingsWindow __init__, , , .

PS:

MainWindow.__init__ Ui_MainWindow.__init__(self), SettingsWindow.__init__ Ui_Dialog.__init__(self). , Ui_* - object. , .

+2

:

class SettingsWindow(QtGui.QDialog):
    def __init__(self, parent = None):
        QtGui.QDialog.__init__(self, parent)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.lineEdit.setText("safa")
        print self.ui.lineEdit.text()

.

+3

Source: https://habr.com/ru/post/1523661/


All Articles