[Interest] QPushButton shortcut works on Qt 4 but not 5

Elvis Stansvik elvstone at gmail.com
Sun May 8 15:45:30 CEST 2016


2016-05-08 12:11 GMT+02:00 Mark Gaiser <markg85 at gmail.com>:

> On Sat, May 7, 2016 at 6:43 PM, Elvis Stansvik <elvstone at gmail.com> wrote:
>
>> 2016-05-07 16:56 GMT+02:00 Mark Gaiser <markg85 at gmail.com>:
>> > On Sat, May 7, 2016 at 3:44 PM, Elvis Stansvik <elvstone at gmail.com>
>> wrote:
>> >>
>> >> 2016-05-07 15:27 GMT+02:00 Elvis Stansvik <elvstone at gmail.com>:
>> >> > Hi all,
>> >> >
>> >> > Maybe I'm doing something completely wrong, but on Qt 4.8.7, this
>> >> > works (pressing Ctrl+O prints "clicked"):
>> >> >
>> >> > 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"
>> >> >
>> >> > but on Qt 5.6.0 it does not (nothing printed on Ctrl+O).
>> >>
>> >> I just tested on a couple of other machines (Qt 5.2.1 and Qt 5.5.1),
>> >> and it worked on both of them. So something broke in Qt 5.6.0? Or Arch
>> >> somehow broke my Qt?
>> >>
>> >> If anyone else is under KDE on Arch and could give it a try, I would
>> >> much appreciate it.
>> >>
>> > can you try to rule out plasma and it's default key bindings. There
>> might
>> > very well be a Ctrl+O global key binding in there.
>> >
>> > Install openbox on your system en logon (via sddm) in an openbox
>> session.
>> > Then try your app and see if it works.
>> >
>> > If that does work then plasma is probably taking that global shortcut.
>> If it
>> > doesn't then the issue is quite a bit deeper.
>>
>> Ah, good idea. I can confirm that it works under Openbox.
>>
>> So now the question is why Plasma (KWin?) seems to swallow a lot of
>> shortcuts.
>>
>> Looking at System Settings -> Shortcuts I can confirm that Ctrl+O is
>> bound to "Open..." under Standard Shortcuts. But I don't understand
>> why something like that is done by Plasma, isn't that an application
>> thing?
>>
>> I also can't get Qt::Key_F2 to work with the above example (it was
>> actually the function keys I was mostly interested in), and that is
>> not bound to anything under System Settings -> Shortcuts.
>>
>> Anyway, I guess it's not a Qt issue, so sorry for being off-topic. But
>> if anyone knows what might be going on I'm idle ears.
>>
>>
> Ah great, you found the real issue: Plasma :)
> now you could try the same on plasma again only with kwin killed.
>
> If that fixes your issue then you know for sure that kwin is doing
> something you don't want and are probably best off by describing a minimal
> case that kwin breaks and post that in the plasma development mailing list (
> plasma-devel at kde.org) to further nail down the issue.
>

Alright, will do. The strange thing is that if I do

    killall kwin_x11
    openbox &
    ./test

from a running KDE session, it's still not working. Neither is

    kquitapp5 plasmashell
    ./test

But if I logout and login to an Openbox session through SDDM, it works
(that's what I tried yesterday, and I double checked today).

So some other KDE process which I'm unaware of is probably causing this.
But it's strange that it works under the very same KDE session if I use Qt
4.8.7 to compile the example, so if you know of any changes which could
have triggered this in 5.6.0..

But yes, I'll report to plasma-devel@ and see what they say.

Thanks,
Elvis


>
>
>> Elvis
>>
>> >
>> >
>> >>
>> >> Elvis
>> >>
>> >> >
>> >> > test.pro for building:
>> >> >
>> >> > TEMPLATE = app
>> >> > greaterThan(QT_MAJOR_VERSION, 4):QT += widgets
>> >> > TARGET = test
>> >> > INCLUDEPATH += .
>> >> >
>> >> > # Input
>> >> > SOURCES += test.cpp
>> >> > HEADERS += test.cpp
>> >> >
>> >> > Any ideas what may be going wrong? My window manager (KWin) is not
>> >> > intercepting Ctrl+O (obviously). And besides, it doesn't seem to
>> >> > matter which shortcut I use.
>> >> >
>> >> > Thanks in advance,
>> >> > Elvis
>> >> _______________________________________________
>> >> Interest mailing list
>> >> Interest at qt-project.org
>> >> http://lists.qt-project.org/mailman/listinfo/interest
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160508/4db66e51/attachment.html>


More information about the Interest mailing list