Qt Creator Keyboard Shortcuts
Navigation
| Shortcut |
Action |
| Home |
Move to line start |
| End |
Move to line end |
| Ctrl + Home |
Jump to file beginning |
| Ctrl + End |
Jump to file end |
| Ctrl + Alt + Up/Down |
Duplicate line |
Code Editing
| Shortcut |
Action |
| Ctrl + Enter |
Insert blank line below |
| Ctrl + Shift + Enter |
Insert blank line above |
| Ctrl + I |
Format selected code |
| Shift + Delete |
Cut current line |
| Ctrl + / |
Toggle comment |
| Ctrl + Shift + R |
Rename variable locally |
| Ctrl + Shift + V |
Clipboard history |
| Ctrl + S |
Save current file |
| Ctrl + Shift + S |
Save all files |
| Alt + Enter |
Show code generation menu |
| Alt + Mouse |
Multi-cursor editing |
Code Navigation
| Shortcut |
Action |
| F1 |
Open help documentation |
| F2 |
Go to symbol definition |
| F4 |
Switch between .cpp and .h |
| Ctrl + Left Click |
Navigate to declaration |
| Ctrl + Shift + U |
Find all symbol references |
| Ctrl + M |
Toggle bookmark |
| Ctrl + K |
Open locator |
| Ctrl + L |
Go to line number |
| Ctrl + Tab |
Switch between open files |
Search Operations
| Shortcut |
Action |
| Ctrl + F |
Find in current file |
| Ctrl + Shift + F |
Find in entire project |
| F3 |
Find next occurrence |
| Shift + F3 |
Find previous occurrence |
Build and Debug
| Shortcut |
Action |
| Ctrl + B |
Build project |
| Ctrl + R |
Run project |
| F5 |
Start debugging |
| Ctrl + Shift + F5 |
Restart debugging |
| F9 |
Toggle breakpoint |
| F10 |
Step over |
| F11 |
Step into |
Window Maangement
| Shortcut |
Action |
| Ctrl + Number |
Switch navigatino panels |
| Alt + Number |
Switch bottom panels |
| Alt + 0 |
Toggle sidebar visibility |
| Ctrl + W |
Close current file |
Configuring Application Icons
Set the window icon and taskbar icon using setWindowIcon():
// mainwindow.cpp
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
{
setWindowIcon(QIcon(":/assets/app_icon.png"));
}
Configure the executable icon by adding a resource entry in the project file:
# project.pro
RC_ICONS = app_icon.ico
Signal and Slot Mapping with QSignalMapper
Use QSignalMapper to route multiple signals through a single handler when identifying the source is necessary:
// widget.h
#include <QSignalMapper>
#include <QWidget>
#include <QPushButton>
class ButtonPanel : public QWidget
{
Q_OBJECT
public:
explicit ButtonPanel(QWidget* parent = nullptr);
signals:
void buttonActivated(const QString& labelText);
private slots:
void handleButtonClick();
private:
QSignalMapper* m_mapper;
};
// widget.cpp
#include "widget.h"
ButtonPanel::ButtonPanel(QWidget* parent)
: QWidget(parent)
, m_mapper(new QSignalMapper(this))
{
QList<QPushButton*> buttons = findChildren<QPushButton*>();
for (QPushButton* button : buttons)
{
connect(button, &QPushButton::clicked,
m_mapper, &QSignalMapper::map);
m_mapper->setMapping(button, button->text());
}
connect(m_mapper, &QSignalMapper::mappedString,
this, &ButtonPanel::buttonActivated);
}