Replace QWidget objects at runtime

前端 未结 2 1278
耶瑟儿~
耶瑟儿~ 2020-11-30 14:56

In my application I have to replace all QLineEdit elements with customized QLineEdit. To do that there are different solutions:

  1. Modify the generated py file fr
2条回答
  •  天涯浪人
    2020-11-30 15:33

    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.

提交回复
热议问题