OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

variable exchange


On 09Oct2018 00:12, Luca Bertolotti <luca72.bertolotti at gmail.com> wrote:
>Hello i'm using python with pyqt but i have a problem on varable:
>I have two class:
[...]
>class Form(QWidget, Ui_Form):
>    """
>    Class documentation goes here.
>    """
>    def __init__(self, parent=None):
>        """
>        Constructor
>
>        @param parent reference to the parent widget
>        @type QWidget
>        """
>        super(Form, self).__init__(parent)
>        self.setupUi(self)
>        self.ftc = Form_cli()....................................etc
[...]
>class Form_cli(QWidget, Ui_Form):
>    """
>    Class documentation goes here.
>    """
>    def __init__(self, parent=None):
>        """
>        Constructor
>
>        @param parent reference to the parent widget
>        @type QWidget
>        """
>        super(Form_cli, self).__init__(parent)
>        self.setupUi(self)
>        self.db = QSqlDatabase()
>        self.tableWidget.setRowCount(1)
>        self.tableWidget.setColumnCount(10)
>
>From the class Form_cli how i can modify a textedit that is in the 
>class Form?

Directly.

Just for clarity, you're working with an instance of Form_cli, which is 
a subclass of Form. So the instance has been initialised by running the 
Form initialiser and then the Form_cli initialiser.

The consequence is that your instance has all the attributes of both. So 
if there's a textedit widget associated with the form just access it by 
whatever name it was given.

Python's not like C++ where only public or protected attributes are 
available from outside the class; there aren't such things. Just use it.

Cheers,
Cameron Simpson <cs at cskk.id.au>