[PyQt] acces to object in different class (Kyle Altendorf)

lucaberto at libero.it lucaberto at libero.it
Fri Nov 18 16:28:45 GMT 2016


Thanks of your reply, but in both the case i obtain
Cornice object has not attribute parent
Luca



> Hello i'm using eric as ide and 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.tabWidget.setCurrentIndex(0)> combo = QComboBox()> self.disegno = Cornice(Form)> > def on_pushButton_7_clicked(self):> """> Slot documentation goes here.> """> # TODO: not implemented yet> #raise NotImplementedError> self.lista_dati_prova = [........]> lista_dati = self.dati_prova> self.lineEdit.setText('test')> self.disegno.cornice(lista_dati)> > class Cornice():> > def __init__(self, parent=None):> """> Constructor> > @param parent reference to the parent widget> @type QWidget> """> lista_dati = []> > def cornice(self, lista_dati):> import math> freqfinale = lista_dati[0]> spostamento = lista_dati[2]> nome_cal = self.lineEdit.text()> > How i can access to self.lineEdit without passing parameter from the > class Form and without using signal, but asking directly from Cornice > class?I'm not sure why you have those restrictions, but you probably mean to do:   self.disegno = Cornice(self)To set the Cornice's parent to that instance of the Form rather than the Form class.  But, Cornice doesn't inherit from QObject or otherwise save the parent parameter.  If it did either of those then you could do one of the following (depending on which option you choose):   self.parent.lineEdit.text()   self.parent().lineEdit.text()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161118/2a9bdffb/attachment.html>


More information about the PyQt mailing list