在 Qt Designer 保存、预览和打印表单

尽管 Qt Designer 's forms are accurate representations of the components being edited, it is useful to preview the final appearance while editing. This feature can be activated by opening the 表单 menu and selecting 预览 , or by pressing Ctrl+R when in the form.

The preview shows exactly what the final component will look like when used in an application.

Since Qt 4.4, it is possible to preview forms with various skins - default skins, skins created with Qt Style Sheets or device skins. This feature simulates the effect of calling QApplication::setStyleSheet() in the application.

To preview your form with skins, open the 编辑 menu and select Preferences...

You will see the dialog shown below:

The Print/Preview Configuration checkbox must be checked to activate previews of skins. You can select the styles provided from the Style drop-down box.

Alternatively, you can preview custom style sheet created with Qt Style Sheets. The figure below shows an example of Qt Style Sheet syntax and the corresponding output.

Another option would be to preview your form with device skins. A list of generic device skins are available in Qt Designer , however, you may also use other QVFB skins with the Browse... 选项。

Viewing the Form's Code

Since Qt 4.4, it is possible to view code generated by the User Interface Compiler (uic) for the Qt Designer form.

选择 View Code... 表单 menu and a dialog with the generated code will be displayed. The screenshot below is an example of code generated by the uic .

Saving and Printing the Form

Forms created in Qt Designer can be saved to an image or printed.

Saving Forms

To save a form as an image, choose the Save Image... option. The file will be saved in .png 格式。

Printing Forms

To print a form, select the Print... 选项。