Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Virion
Competition winner
Posts: 2148 Joined: Mon Dec 18, 2006 5:04 am
Post
by Virion » Fri Feb 12, 2010 6:27 pm
Code: Select all
void QIrrlichtWidget::keyReleaseEvent(QKeyEvent *event)
{
if ( device != 0 )
{
switch(event->key())
{
case Qt::Key_W:
{
std::cout<< "W button" << std::endl;
}
break;
default:
return;
}
}
}
Weird, mouse event works but not key event. What is wrong with my code? Anyone using Qt here?
For mouse, it works:
Code: Select all
void QIrrlichtWidget::mouseReleaseEvent(QMouseEvent* event)
{
if ( device != 0 )
{
switch (event->button())
{
case Qt::LeftButton:
{
std::cout<< "left button" << std::endl;
}
break;
case Qt::RightButton:
{
std::cout<< "right button" << std::endl;
}
break;
default:
return; // Cannot handle this mouse event
}
}
}
Last edited by
Virion on Fri Feb 12, 2010 7:57 pm, edited 1 time in total.
Virion
Competition winner
Posts: 2148 Joined: Mon Dec 18, 2006 5:04 am
Post
by Virion » Fri Feb 12, 2010 7:57 pm
Problem fixed. Have to grab the keyboard input when initialize the widget class
QIrrlichtWidget::QIrrlichtWidget( QWidget *parent )
: QWidget(parent)
{
// Wait for the init() call
device = 0;
// Default to Open GL
driverType = irr::video::EDT_OPENGL;
this->grabKeyboard();
}
Escen
Competition winner
Posts: 167 Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:
Post
by Escen » Fri Feb 12, 2010 10:27 pm
Hi Virion,
I was not using Key-event yet, bud notes that it was not working either.
Thanks for figure this out.
Virion
Competition winner
Posts: 2148 Joined: Mon Dec 18, 2006 5:04 am
Post
by Virion » Sat Feb 13, 2010 5:20 am
Escen wrote: Hi Virion,
I was not using Key-event yet, bud notes that it was not working either.
Thanks for figure this out.
I'm glad it helps.