You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Saturday, May 24th 2014, 3:40am

KeyRelease event being fired without KeyPress event on Qt 5.3.0 x64 - Linux Mint KDE

Hi!

I'm trying to send KeyEvents to a QWebFrame (flash plugin) on Linux. Everything's working but accented characters.
When I type "´" I get only a KeyRelease event. Also, if I press "e" after "´" it still fires only the KeyRelease event and no KeyPress event.

I'm using an eventFilter on QApplication.

I've wrote a minimal example to reproduce the problem:

mainwidget.h:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <QApplication>
#include <QWidget>
#include <QKeyEvent>
#include <QMap>
#include <QDebug>

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    MainWidget(QWidget* parent = 0) : QWidget(parent)
    {
        qApp->installEventFilter(this);
    }

    ~MainWidget() { }

    bool eventFilter(QObject* object, QEvent* event)
    {
        if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
        {
            QKeyEvent* ke = dynamic_cast<QKeyEvent*>(event);

            if (ke)
            {
                qDebug() << ke;

                static QMap<int /* key */, int /* >0=press | <0=release*/> keys;

                if (ke->type() == QEvent::KeyPress) // Always accept key press.
                {
                    keys[ke->key()]++; // Pressed
                }
                else if (ke->type() == QEvent::KeyRelease)
                {
                    if (keys[ke->key()] <= 0) // Not pressed but got KeyRelease?!
                    {
                        qDebug() << "Buggy event: " << ke << ". KeyRelease without KeyPress.";
                    }
                    else // Was pressed before.
                    {
                        keys[ke->key()]--; // Release
                    }
                }
            }

            return true;
        }

        return QWidget::eventFilter(object, event);
    }
};

main.cpp:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
#include <QApplication>
#include "mainwidget.h"

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

    MainWidget w;
    w.show();

    return a.exec();
}


I get this output:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
QKeyEvent(KeyPress, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)
QKeyEvent(KeyPress, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 1001251, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001251, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 1001251, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001251, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 1001251, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001251, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyPress, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 1001253, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001253, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 1001253, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001253, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 1001253, 0, """", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 1001253, 0, """", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)
Buggy event:  QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1) . KeyRelease without KeyPress.
QKeyEvent(KeyPress, 45, 0, ""e"", false, 1)
QKeyEvent(KeyRelease, 45, 0, ""e"", false, 1)


I just can't get the project working without these KeyPress events being correctly fired. I'm also trying to find a workaround, but generating an event didn't worked with the flash plugin.

Do you know how I can solve this problem or any workaround?

Thanks in advance.

Update 1:
Also, the same happens if I use keyPressEvent and keyReleaseEvent overloads.

Update 2:
Ok, I've just found this: http://www.qtcentre.org/threads/4653-Han…n-keyPressEvent()
So the issue is with dead keys not being sent to the flash plugin inside QWebView.
I can confirm that the content will handle dead keys as it does in Chromium and in 4.8 version of Qt.

So, is there any way to make it works in the flash plugin?

Update 3:
The dead keys works on another websites inside QtWebkit, but just not when using flash plugins.

Update 4:
Bug report: QTBUG-39252

This post has been edited 5 times, last edit by "Rafaelfsilva" (May 24th 2014, 8:26pm)