I just upgraded to Qt 5.5.0 from Qt 5.3.2 and now my key presses are not 
working.  I am using QGuiApplication::focusObject to get the current object to 
send key press events to for a 5-way button I use on my embedded system to 
duplicate the arrow keys on a keyboard.
Here is the code that sends the key press events
        // Yes, setup the key event information        QKeyEvent *event1 = new 
QKeyEvent(QKeyEvent::KeyPress, key, Qt::NoModifier, "", false);        
QKeyEvent *event2 = new QKeyEvent(QKeyEvent::KeyRelease, key, Qt::NoModifier, 
"", false);
        // Get the gui item which currently has focus        QQuickItem 
*receiver = qobject_cast<QQuickItem *>(QGuiApplication::focusObject());
        qDebug() << "receiver: " << receiver;
        // Is there an item in the gui that has focus?        if (receiver && 
!m_TestController->isButtonTestActive())        {            // Yes, send the 
key press and release events to it to simulate a key press            
receiver->window()->sendEvent(receiver, &event1);            
receiver->window()->sendEvent(receiver, &event2);        }
code 

In Qt 5.3.2 my qDebug() print would read...
receiver:  QQuickImage (this = 0x3bb448 , name= "" , parent = 0x3bad10 , 
geometry = QRectF(0,0 110x40) , z = 0 )

OR
receiver:  MenuList_QMLTYPE_30 (this = 0x6856e8 , name= "" , parent = 0xa80958 
, geometry = QRectF(0,39 430x188) , z = 0 )

However on Qt 5.5.0 my qDebug print always reads...
receiver:  PageStack_QMLTYPE_13(0x459958, parent=0x398d68, geometry=0,0 480x272)

It seems like to me QGuiApplication::focusObject is broken in Qt 5.5.0?  Or is 
there a new way to do this in Qt 5.5.0?
Thanks!
Nate
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to