blackberry/Qt

Keyboard input occasionally fails for widgets with child widgets

absmall opened this issue · 2 comments

This issue is somewhat intermittent - I have seen it appear and disappear with just whitespace changes to the code.

Compiling the program below, it should print a message to the console (or log file on playbook) on any keyboard input, this is what it does in linux. The qterm.h file contains includes of a few irrelevant headers - removing those irrelevant headers includes somehow makes it do this on playbook too (that is, without the includes, it works as I expect). But compiling the code exactly as-is, it does not print any message when the VKB is activated and a key is pressed on it. Adding prints to the Qt code, I can see that QWidget::setFocus() is called at some point on startup in the success case, and is not called in the failure case, but I haven't gotten further than that in debugging. If the 'new QPushButton(this) is commented out, then the problem never happens in my testing.

qterm.h:

include

include

include

include

class QTerm : public QWidget
{
Q_OBJECT
public:
QTerm(QWidget *parent = 0);
~QTerm( );

protected:
void keyPressEvent(QKeyEvent *);
};

qterm.cpp:

include

include

include

include <qterm.h>

include <stdio.h>

QTerm::QTerm(QWidget *parent) : QWidget(parent)
{
new QPushButton(this);
}

QTerm::~QTerm()
{
}

void QTerm::keyPressEvent(QKeyEvent *event)
{
printf("Key %d pressed\n", event->key());
fprintf(stderr, "Key %d pressed\n", event->key());
}

int main(int argc, char *argv[])
{
QCoreApplication::addLibraryPath("app/native/lib");
QApplication app(argc, argv);

QTerm term(NULL);
term.show();

return app.exec();

}

Changing the whitespace in the source file shouldn't be causing a change at runtime. I've not been able to reproduce this issue with my current sandbox and we hope to be pushing some new fixes very soon.

Seems to be fixed in the new code drop