QAction *action = new QAction("Save", parent); action->setIcon(QIcon(":/images/save.png"));
QAction *copyAction = new QAction("&Copy", this); copyAction->setShortcut(QKeySequence::Copy); connect(copyAction, &QAction::triggered, this, &MyClass::copy);In this example, a new QAction is created with the name "Copy" and a keyboard shortcut defined by the QKeySequence class. The QAction is then connected to a slot function called "copy" in a class called "MyClass" using the connect() function. When the QAction is triggered, the copy() function will be executed. Package library: Qt Core and Qt Widgets