Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
[Previous: Using Containers] [Contents]
Qt Designer's connection editing mode allows objects in a form to be connected together using Qt's signals and slots mechanism. Both widgets and layout objects can be connected via an intuitive connection interface, and Qt Designer will present a menu of compatible signals and slots to use for each connection made. When the form is saved, the connections are preserved so that they will be ready for use when your project is built.
To begin connecting objects, enter connection mode by opening the Form menu and selecting Edit Connections. All widgets and layout objects on the form can be connected together. Spacers just provide spacing hints to layouts, so they cannot be connected to other objects.
![]() | Highlighted objects When the cursor is over an object that can be used in a connection, the object will be highlighted, and can be connected to other objects on the form. |
To make a connection, hold down the left mouse button over a highlighted object, and drag the cursor towards the object you want to connect it to. As you do this, a line will extend from the source object to the cursor. If the cursor is over another object on the form, the line will end with an arrow head that points to the destination object, indicating that a connection will be made between the two objects when you release the mouse button.
![]() | Making a connection The connection path changes shape as the cursor moves around the form. As it passes over objects, they are highlighted, indicating that they can be used in a signals and slots connection. |
When you are satisfied that the correct objects will be connected, release the mouse button to make the connection. A dialog displays the signals from the source object and the slots from the destination object that can be used to connect the two objects.
![]() | Choosing signals and slots The Configure Connection dialog presents the signals that can be emitted by the source object alongside a list of compatible slots in the destination object. When you select a signal, the dialog automatically updates the list of compatible slots to ensure that a valid connection is made. |
To complete the connection, select a signal from the source object and a slot from the destination object, then click the OK button. Click Cancel if you wish to abandon the connection.
You can make as many connections as you like between objects on the form. If you connect a lot of objects together, it may be necessary to tidy up the connections to make the form maintainable for other designers. Qt Designer provides facilities for editing the appearance of connections on the form which do not influence the way that the widgets behave when your application is deployed.
If many connections are made between objects on a form, it can appear a little crowded when viewed in connection editing mode. To help with this problem, Qt Designer's connection editor allows the paths taken by the connections to be adjusted by allowing the user to re-route the paths between objects. This is purely a cosmetic concern: The .ui files created by Qt Designer will contain the same basic information about the connections, and this will result in the same code being generated.
![]() | Editing connection paths The route taken by connection paths can be adjusted by moving nodes around on the form. Extra nodes can be added by holding down Ctrl and clicking on a path segment. Extra nodes help keep connection paths tidy, and make the form more maintainable. The labels that show the signal and slot for each connection can also be repositioned to make the form tidier. |
By default, connection paths are created with two nodes that can be freely positioned on the form. The first node is initially placed on the form outside the source object, but it can be dragged inside the source object to control where the connection path begins. The second node is usually located inside the destination object, and it determines where the connection path ends. This node can be accessed by clicking the last path segment. It can either be repositioned within the destination object, or dragged outside.
![]() | Deleting connections The whole connection can be selected by clicking on any of the path segments. Once selected, connections can be deleted, and they will not be set up in the .ui file. |
[Previous: Using Containers] [Contents]
Copyright © 2004 Trolltech | Trademarks | Qt 4.0.0-b1 |