Connecting Widgets To Each Other

We have one goal left: Enabling the Extra Cheese check box when the Anchovies check box is checked as well disabling it when the Anchovies check box is unchecked. You might expect that this means more additions to the PizzaEntryImpl class, but this is not the 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 by any other of the previously described means and “draw” a connection between the Anchovies check box and the Extra Cheese. In the Connections dialog that appears, connect the toggled(bool) signal, which is emitted when the Anchovies check box 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.