Dialogs
Dialogs
The CDPBaseButtonPopDlg widget makes it possible to open separate UI files when the button is pushed. Enter the name of the UI file in the property named, uiFileName. This will make the UI file load dynamically when the button is clicked. The UI file must be placed within the Application directory (the directory that also contains mainwidget.ui) or added to the application as a resource. The latter is required to ensure that studio can locate the UI independently of the working directory.
Create UI Files
Create UI files using File > Create New... and select Qt > Qt Designer Form. In the next dialog, Choose a Form Template, and select CDPBaseDialog under Custom Widgets. Click Next and add name and location in the following dialog. The defaults should be fine in the remaining steps.
The following can be added as a dialog style sheet if you do not want to show the content background while editing the dialog form:
QWidget > QWidget { background: transparent; }
Select Different Dialogs in Design Mode
The mainwidget.ui file will get selected every time you enter Design mode even though work was being done on a different form. Switch between project forms by clicking on the form selector button in the top left corner of the page. Forms that have been opened from the file menu are selected by clicking on the file selector to the right of the form selector button. It will always show the name of the form that is currently showing.
Create a Resource File and Add a Dialog
Go into Code mode and right-click the GUI application where we want to add the resource file. Select Add New... and Qt > Qt Resource File. Give it a proper name and select the defaults in the following dialogs. This creates and adds a resource file to the application.
Add an existing UI file to the resource file. First, locate the resource file within the application tree, right-click and select Open in Editor. In the editor, click Add > Add Prefix and edit the prefix to /. Click add one more time, but this time we'll select Add Files. Select the UI file. Afterward, it could be useful to select it and add an Alias to avoid long names in the uiFileName property.
Settings Dialogs
A Settings Dialog will often allow the user to configure different settings and then decide whether to reset or save the changes. To achieve this, we will have to configure all input widgets, like spin boxes, line edits, and combo boxes to not immediately send their values to the control system when changed. In most input widgets, this is done by setting the property named updateOnSlotOnly. When this property is true
, the widget will only send new values to the control system when its sendToCdp slot is triggered. The input widgets have a similar slot for resetting their value to be identical to the remote value, resetToCdp.
Instead of connecting the save and reset buttons to all input widgets in the settings dialog, we can place the widgets in a Container widget. The Container has slots similar to reset and save in the input widgets and will execute on all children when triggered.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.