Chapter 7. Customizing and Integrating Qt Designer

Table of Contents
Customizing Qt Designer
Creating and Using Templates
Integrating Qt Designer with Visual Studio
Importing Foreign File Formats

Customizing Qt Designer

Qt Designer can be customized in two ways: you can add custom widgets, and you can change aspects of how Qt Designer works. Custom widgets are covered in Chapter 5 "Creating Custom Widgets". This section will focus on customizing Qt Designer itself.

Qt Designer's toolbars are all dockable so they can be dragged by their toolbar handles and arranged how you like. The Files, Object Hierarchy, Property Editor and Output Windows are also dockable so you can also drag them to the positions that you prefer. You can also make them into floating windows by dragging them outside Qt Designer's dock areas.

General preferences can be set by clicking Edit|Preferences to invoke the Preferences dialog. If you check the 'Restore last workspace on startup' checkbox then Qt Designer will remember the sizes and positions of the toolbars and the dockable windows. You can change Qt Designer's main window background either by selecting a color or a pixmap. You can also switch off the grid (uncheck Show Grid) since using layouts makes the grid redundant.

The Preferences dialog may have additional tabs, depending on what plugins you have installed. We'll describe the C++ Editor tab since this is installed by default.

The C++ Editor tab is used to set your preferred fonts for syntax highlighting in Qt Designer's code editor. The base font for all elements is set in the 'Standard' element which is the last item in the list. If you want one font to be used throughout then set the 'Standard' font and all the other elements will inherit its setting.

Qt Designer's Code Editor

The code editor is available if an Editor plugin is installed. The C++ Editor plugin is installed by default.

The code editor provides the following keystrokes:

  • Left Arrow -- Moves the cursor one character left

  • Right Arrow -- Moves the cursor one character right

  • Up Arrow -- Moves the cursor one line up

  • Down Arrow -- Moves the cursor one line down

  • Page Up -- Moves the cursor one page up

  • Page Down -- Moves the cursor one page down

  • Backspace -- Deletes the character to the left of the cursor

  • Home -- Moves the cursor to the beginning of the line

  • End -- Moves the cursor to the end of the line

  • Delete -- Deletes the character to the right of the cursor

  • Ctrl+A -- Moves the cursor to the beginning of the line

  • Ctrl+B -- Moves the cursor one character left

  • Ctrl+C -- Copies the selected text to the clipboard (also Ctrl+Insert under Windows)

  • Ctrl+D -- Deletes the character to the right of the cursor

  • Ctrl+E -- Moves the cursor to the end of the line

  • Ctrl+F -- Invokes the Find Text dialog

  • Ctrl+G -- Invokes the Goto Line dialog

  • Ctrl+H -- Deletes the character to the left of the cursor

  • Ctrl+I -- Indent the line or selected text that contains the cursor

  • Alt+I -- Starts incremental search (see below)

  • Ctrl+K -- Deletes from the cursor position to the end of the line

  • Ctrl+N -- Moves the cursor one line down

  • Ctrl+P -- Moves the cursor one line up

  • Ctrl+R -- Invokes the Replace Text dialog

  • Ctrl+V -- Pastes the clipboard text into line edit (also Shift+Insert under Windows)

  • Ctrl+X -- Cuts the marked text, copy to clipboard (also Shift+Delete under Windows)

  • Ctrl+Y -- Redoes the last operation

  • Ctrl+Z -- Undoes the last operation

  • Ctrl+Left Arrow -- Moves the cursor one word left

  • Ctrl+Right Arrow -- Moves the cursor one word right

  • Ctrl+Up Arrow -- Moves the cursor one word up

  • Ctrl+Down Arrow -- Moves the cursor one word down

  • Ctrl+Home Arrow -- Moves the cursor to the beginning of the text

  • Ctrl+End Arrow -- Moves the cursor to the end of the text

  • Tab -- Completion (see below)

To select (mark) text hold down the Shift key whilst pressing one of the movement keystrokes, for example, Shift+Right Arrow will select the character to the right, and Shift+Ctrl+Right Arrow will select the word to the right, etc.

Pressing Alt+I starts incremental search. The characters you type will appear in the Incremental Search line edit in the Search toolbar and the cursor will be moved to the first matching text in the editor. As you type the search will continue. Press Return to move to the next match and press Esc to cancel the search at the position you've reached.

Pressing Tab after you've typed one or more characters invokes completion. Completion works like this: start typing some text then press Tab. If the editor can find another item of text that begins with the same characters it will complete your text for you; if it finds more than one possibility it will pop up a list of choices. You can use the arrow keys to choose a piece of text then press Return, or press Esc to continue typing. You can switch off completion in the Preferences dialog.

When you enter -> or . the editor will pop up a command completion list; use the arrow keys to move to the item you want and press Return, or press Esc to ignore the list.