Connecting Widgets To Each Other

We have one goal left: Enabling the Extra Cheese checkbox when the Anchovis checkbox is checked as well disabling it when the Anchovis is unchecked. You might perhaps expect that this needs more additions to the PizzaEntryImpl class, but this is not case: We have the fortunate situation here that we can just connect the right signals and slots to each other and have Qt Designer and uic do the rest.

Start Qt Designer again and load pizza.ui. This time, we do not need to create our own slots but just use predefined ones. So start the connection tool by hitting F3 or any other of the previously described means and “draw” a connection between the Anchovis checkbox and the Extra Cheese. In the Connections dialog that shows, connect the toggled(bool) signal which is emitted when the Anchovis checkbox is operated to the setEnabled(bool) slot. Close the dialog with OK. That's all! Save your work and compile your program as described in the first section in this tutorial. Run the program and check that it actually does what we wanted.