PDA

View Full Version : How to get key event in QObject (or how to post a key event to another QObject)



behnia_k
31st October 2007, 14:04
Hi all,
I dont use any QWidget in my project (use QTimer and QSocket)
How to handel keyboard.
i use Qt 2.3.0


class clMyObject : public QObject
{
public:
clMyObject(QObject *parent=0, const char *name) : QObject(parent, name) {};
//
bool event(QEvent * e)
{
if (e->type == QEvent::KeyPress)
{
qDebug("Key press");
}
else
{
qDebug("no Key press event %d", e->type());
}
//
return QObject::event();
};
};

int main(int argc, char **argv)
{
QAplication a(argc, argv, false);
//
clMyObject MyObject(a);
//
return a.exec();
}

kernel_panic
31st October 2007, 14:14
i think not with this. you have to read the stdin.
with

QTextStream textStream(stdin);