9.7.1.  QtCreator Integration with Designer

[ fromfile: creator-form-integration.xml id: creator-form-integration ]

QtCreator integrates Designer with an IDE in a very convenient way, generating the integration code and function bodies of slots for you, for classes where it understands the correspondence between the UI file and its class files. You can create new .ui files, header files, and corresponding cpp files all at once, from QtCreator's File -> New -> Qt -> Designer Form Class. Figure 9.20 shows you the three styles of code generation that it supports.

Figure 9.20.  QtCreator Designer Code Generation Options

QtCreator Designer Code Generation Options

For child objects that need to connect to one another (e.g., GUI components of a QMainWindow) QtCreator has a nice convenience feature, shown in Figure 9.21. You can right-click on any signal-emitting component in the Widget editor (e.g., the Save pushbutton), or any action in the Action Editor (e.g., actionSave), and select Go to slot. Next, select a signal from the list that pops up (e.g., triggered()). QtCreator generates a private slot for you – a prototype in the header file and a stub in the implementation file – if you do not already have one with the name that is generated (e.g., on_actionOpen_triggered()). You can complete the definition of the new slot by adding the necessary operational details. The signal you select is automatically connected to that newly defined slot at runtime. You will not find the connect statement in the implementation (.cpp) file. Instead, the connections are made by the QMetaObject::connectSlotsByName() function.

Figure 9.21. QtCreator: Go to Slot

QtCreator: Go to Slot

Section 10.5 discusses an application written entirely in QtCreator using these tools.