AFAIK, only connectors can be glued to others elements and remain connected when you move shapes. You should then use a connector to attach it to one or two shapes (depending on the need to attach the connector on both ends). The connector tool is loated in the bottom toolbar.
The second problem is connectors can be attached only to the middle of the rectangle sides by default. To attach a connector to a corner, you must add a new glue point in a corner with Edit
>Glue Points
.
After that add your “line” as a connector. When you hover the tool near a shape, the glue points become visible. Click on one of them and drag the connector to its target end. Release mouse button.
To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!