Using the QKeySequenceWidget

How to use the QKeySequenceWidget

In qmake-based projects

For using QKeySequenceWidget in your qmake-based project you must copy "qkeysequencewidget" directory to your source tree. And include qkeysequencewidget.pri into your *.pro file.

For example see projects in "demos" directoy .

In qmake-based projects

For using QKeySequenceWidget in your CMake-based project you must coy "qkeysequencewidget" directory to your source tree. And include into main CMakeLists.txt this strings:

Then add "qkeysequencewidget" into target_link_libraries section for your project.

For example, see CmakeLists.txt in root directoy.

Sample code

This sample is shows a simple use of the widget in run-time.

    // create new QKeySequenceWidget with empty sequence
    QKeySequenceWidget *keyWidget = new QKeySequenceWidget;
    
    // Set sequence as "Ctrl+Alt+Space"
    keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space"));
    
    // set clear button position is left
    setClearButtonShow(QKeySequenceWidget::ShowLeft);
    
    // set cutom clear button icon
    setClearButtonIcon(QIcon("/path/to/icon.png"));
    
    // connecting keySequenceChanged signal to slot
    connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence)));

Plugin for QtDesigner

For using QKeySequenceWidget in QtDesigner you needs build designer-plugin. This located in "designer-plugin" directory.

Installing QKeySeqenceWidgetPlughin^

In Linux:

make install (as root)

In Windows:

Copy QKeySequnceWidgetPlugin.dll to ${QT_DIR}/plugins/designer

It builded only qmake, CMake not supported.