I am working on a PyQt5 project where I am trying to integrate a few custom widgets into my main application but I am facing some issues with widget layout and signal handling; when I add the custom widgets to my main window they either do not appear in the correct position or overlap with other element. Also I have tried adjusting the layout but can not seem to get it right.
I am struggling to correctly connect signals and slots for these widgets. The signals do not seem to trigger as expected and I am wondering if I might be missing something in how I have set up the event handling.
Is there anyone who has experienced a similar problem or can someone give a basic example of correctly integrating custom widgets and controlling their signals?
This suggests that they (or their child elements) aren’t correctly being constrained by the layout. To have the widget behave properly, you need it’s contents to respond to the space given to it by the layout you’re putting it into. This only happens automatically if everything inside the custom widget is also managed through a layout.
How did you built the custom widgets? If it is in Qt Designer, make sure that you don’t have any red error signs against the layouts.
This indicates that the widgets under that point aren’t constrained by a layout & in that case they’ll just be floating around relative to the origin (top left) of the parent.
This probably also explains the signals, since the widgets may be appearing behind other widgets in this case.
If you’ve build the widget with code, can you post an example (just the construction of the custom widget, with layouts/etc. in the init is needed)