Make sure the clicked() signal of the button is connected to the accept() slot of the form.