Basic QPushButton keyboard shortcut test fails under KDE session

Elvis Stansvik elvstone at gmail.com
Sun May 8 13:56:32 UTC 2016


Hi all,

Recently I reported to qt-interest that I was having problems with the
following small test case under Qt 5.6.0, because I thought it was a
Qt problem:


test.cpp:

#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QWidget>
#include <QDebug>

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0) : QMainWindow(parent) {
        QPushButton *button = new QPushButton("Click Me (Ctrl+O)");
        button->setShortcut(QString("Ctrl+O"));
        connect(button, SIGNAL(clicked()), this, SLOT(onClicked()));

        setCentralWidget(button);
    }

public slots:
    void onClicked() {
        qDebug() << "clicked";
    }
};

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    MainWindow window;
    window.show();

    return app.exec();
}

#include "moc_test.cpp"


test.pro:

TEMPLATE = app
greaterThan(QT_MAJOR_VERSION, 4):QT += widgets
TARGET = test
INCLUDEPATH += .

# Input
SOURCES += test.cpp
HEADERS += test.cpp


Hitting Ctrl+O would not print "clicked" as expected.


But then I tested logging out and into an Openbox session, and it
worked from there. The strange thing is that it works with Qt 4.8.7
under the very same KDE session where it fails with Qt 5.6.0.

Even stranger is that neither:

    killall kwin_x11
    openbox &
    ./test

which I would have thought would give the same result as a logout +
login to Openbox, nor

    kquitapp5 plasmashell
    ./test

works, if I do that in the running KDE session. So there must be some
other KDE process I'm unaware of which intercepts the shortcut.

I'm now unsure whether the problem is with Qt 5.6.0, with some
KDE/Plasma component, or somehow with both.

Would appreciate a lot if someone could check and see if they can reproduce.

I've tried with other shortcuts like F2, which unlike Ctrl+O is not
bound to anything under Standard Shortcuts in System Settings ->
Shortcuts, and it's not working either.

Thanks in advance for any advise! I'm attaching the test case as well.


[1] http://lists.qt-project.org/pipermail/interest/2016-May/022505.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar.gz
Type: application/x-gzip
Size: 653 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160508/cf406b2b/attachment.bin>


More information about the Plasma-devel mailing list