PDA

View Full Version : How to send Key_Left/Key_Right Event to QListWidget



nrabara
18th May 2010, 13:36
Hi,

I am using qt/embedded on Custom ARM platform. I have used QListWidget to display wallpapers in thumbnail view.
I have few navigation keys on my board which I want to use as key event.

How to send Key_Left/Key_Right keypress event to ListWidget?

I know how to get event, by using customising keyPressEvent as below in code.



void Widget::keyPressEvent(QKeyEvent * event)
{
switch(event->key())
{
case Qt::Key_Left;
qDebug()<<"Key_Left";
break;

case Qt::Key_Right;
qDebug()<<"Key_Right";
break;

default:
break;
}
event->accept();
}


But I dont know how to post KeyPressEvent (Key_Left/Key_Right).

I can post key-press event by using QCoreApplication::PostEvent, but how to post Key_Left event instead of keyPressed/keyReleased .

Any suggestion would be appreciable.

wysota
18th May 2010, 13:39
"Key_Left" is a keyPress or keyReleaseEvent. You don't post it "instead" of key press or key release.

nrabara
18th May 2010, 17:44
Is there any way to post Key_Left event to widget? Or Simply it's not possible?

wysota
18th May 2010, 17:52
Which part of my post you didn't understand? You can post a keyPressEvent or a keyReleaseEvent containing a Key_Left to any widget you want. There is no "Key Left Event".