<div dir="ltr"><div><div><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Il giorno ven 4 lug 2025 alle ore 17:09 Luca Bertolotti <<a href="mailto:luca72.bertolotti@gmail.com">luca72.bertolotti@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Sorry i have calle thread.start ,but i never copy tho the original message<div><br></div><div>i can do as follow:</div><div><br></div><div><div>Class Read(QObject):</div><div>    letto = pyqtSignal(str)</div><div>    finished = pyqtSignal(str)</div><div>    def __init__(self, parent=None):<br>        super().__init__(parent=None)<br><br>        self.timer_leggo_x_y =QTimer()<br>        self.timer_leggo_x_y.timeout.connect(self.leggo_x_y)<br>        self.timer_leggo_x_y.start(250)</div><div>     def run(self):</div><div>       variable = self.reader_v.read()</div><div>       self.letto.emit(variable)</div><div>       self.finished.emit()</div><div>       </div><div><br></div><div><br></div>class Form(QWidget, Ui_Form):<br>    """<br>    Class documentation goes here.<br>    """<br><br>    def __init__(self, parent=None):<br>        """<br>        Constructor<br><br>        @param parent reference to the parent widget (defaults to None)<br>        @type QWidget (optional)<br>        """<br>         super().__init__(parent)<br>        self.setupUi(self)<br><div>        self.tableWidget.setRowCount(200)...........</div><div>        self.reader = .............</div><div>        self.read_pos = Read()</div>        self.read_pos_thread = QThread()<br>        self.read_pos.moveToThread(self.read_pos_thread)<div>        self.read_pos.reader_v = self.reader</div><div>        self.read_pos_thread.started.connect(self.read_pos.run)</div><div>        self.read_pos.letto.connect(self.scrivo_x_y)</div><div>        self.read_pos.finished.connect(self.reset)</div><div>        self.read_pos_thread.start()</div><div><br></div><div>    def scrivo_x_y(self, variable):</div><div>         self.lineEdit.setText(variable)</div><div>    </div><div>    def reset(self):</div><div>          self.read_pos_thread.start()</div></div></div></blockquote><div><br></div><div>Sorry but your update is still not appropriate: the QTimer is connected to a function that doesn't exist ("leggo_x_y" is now gone), and we still don't know the actual problem you have. Does the code run or not? If it does run, what *demonstrable* problems are you facing? Where is the code for that "reader"? Do you get any debug output or relevant crash traceback? Can you explain your need for using threading (eg: the "Servodrive" takes too much time to reply)?</div><div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container">Multithreading and dealing with external I/O may be quite complex, we cannot help you with vague explanations and incomplete/partial code.</div></div><div>Please take your time to carefully explain your context, the reasoning behind your choices (threading), what actual problems you have with your current attempts, and include relevant debug output (also, try to run the code in a terminal or prompt if you're using an IDE). Finally, ensure you provide an appropriate and comprehensive minimal reproducible example with proper syntax and indentation.<br></div></div><br></div>Regards,<br></div><div>MaurizioB</div><div><br></div><div class="gmail_quote gmail_quote_container">PS: having a "parent" argument in the "<span style="font-family:monospace">def __init__()</span>" of the subclass is quite meaningless if you then call <span style="font-family:monospace">super().__init__(parent=None)</span>. If you don't want the QObject instance to have a parent (which makes sense, if you're going to move it into another thread), remove that keyword argument from both of them, as they're useless and redundant; if you still need a reference to "some parent", you could just call <span style="font-family:monospace">super().__init__()</span> without the "parent=None" keyword (as it's implicit) and eventually create an instance attribute for that parent if you need that reference, but be aware that if that parent isn't a thread-safe object (eg: a widget) you shall *never* try to access it from that thread (anything directly called within the "<span style="font-family:monospace">run()</span>" call).<br></div><div><div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div></div></div></div>