The m_checkbox_lock_mouse QCheckBox was only conditionally being added to the layout, leaving it unmanaged and leaking Setting the parent will allow it to be managed.