In my application I have to replace all QLineEdit elements with customized QLineEdit. To do that there are different solutions:
I didn't go through all of your code...
My guess though is, that even though you've replaced the widget in the layout, window.txt_line_1 still points to the deleted object.
So, in your replacement-procedure you'll also have to update this attribute.
So, adding
setattr(parent, obj_name, qt_obj);
to _replace_qlineedit_from_gridlayout might do the trick.