Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_kernel_qshortcut.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QShortcut>
5#include <QKeySequence>
6
7class MyShortcut : public QShortcut
8{
9 void example()
10 {
11 QShortcut *shortcut;
12 QObject *parent;
13 //! [0]
14 shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open")),
15 parent);
16 //! [0]
17
18
19 //! [1]
20 setKey(0); // no signal emitted
21 setKey(QKeySequence()); // no signal emitted
22 setKey(0x3b1); // Greek letter alpha
23 setKey(Qt::Key_D); // 'd', e.g. to delete
24 setKey('q'); // 'q', e.g. to quit
25 setKey(Qt::CTRL | Qt::Key_P); // Ctrl+P, e.g. to print document
26 setKey(tr("Ctrl+P")); // Ctrl+P, e.g. to print document
27 //! [1]
28 }
29};