Emile Cormier
Emile Cormier

Reputation: 29229

Switching between .ui and .cpp in Qt Creator

In Qt Creator, is there an easy way to directly switch between the Design view and the .cpp file associated with the form (and vice-versa)?

When I go from Design mode to Edit mode (Ctrl-2), it annoyingly shows me the XML code of the .ui file, so I have to manually pick the .cpp file.

When I'm in the .cpp file of a form, the Design mode icon and shortcut (Ctrl-3) are disabled, so I have to manually pick the .ui file.

There must be a better way to switch between ui <--> cpp.

Upvotes: 6

Views: 2468

Answers (1)

Emile Cormier
Emile Cormier

Reputation: 29229

Buried in the menu, is the Tools -> Form Editor -> Switch Source / Form command. It has the Shift-F4 hotkey and does exactly what I was looking for.

F7 doesn't seem to be bound to any command, so I rebound the FormEditor/FormSwitchSource command to use F7 as the keyboard shortcut. I can now switch between ui <--> cpp with a single keypress!

EDIT:

There's a known bug with Qt Creator where it doesn't save the keyboard shortcut for the FormEditor/FormSwitchSource command.

Upvotes: 8

Related Questions