Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, September 1998
How use keyPressEvent?


Message 1 in thread

Hi, 

I have a simple question:
In a QDialog, I just want to enable the Enter-Key to simulate the Okay
button being pressed.
In the qdialog.html file I read that I could do it with


void QDialog::keyPressEvent ( QKeyEvent * e ) .

What do I have to use for "QKeyEvent *e"? I can`t manage to find it out
from the .html manuals.

Thanks, 

Martin
  




***********************************************************************

Martin Goebel				      @    @
Algibe de la Vieja 5			       @@@@
18010 Granada				      @@@@@@@@@@@@
Espaņa						@@@@@@@@@  @
Tel. (0034)-958-293947				@ @   @ @
E-Mail: x7046364@turing.ugr.es		       @  @   @ @


Message 2 in thread

On Tue, 1 Sep 1998, Martin Goebel wrote:

> void QDialog::keyPressEvent ( QKeyEvent * e ) .
> 
> What do I have to use for "QKeyEvent *e"? I can`t manage to find it out
> from the .html manuals.

If you look in the src file for the showpic.cpp program, there is an
example of the keyPressEvent() near the bottom. It is checking for a 'q'
and a 'r' but you can change it to look for a return ACII value.

This may not be the best way to do it but I think it will work.

Keith


Message 3 in thread

Martin Goebel <x7046364@turing.ugr.es>
> void QDialog::keyPressEvent ( QKeyEvent * e ) .
> 
> What do I have to use for "QKeyEvent *e"? I can`t manage to find it out
> from the .html manuals.

It's there.  For example, look at the function you mention:
QDialog::keyPressEvent().  In http://www.troll.no/qt/qdialog.html
there is a little text about it, starting:

void QWidget::keyPressEvent ( QKeyEvent * e ) [virtual protected]
...

Now, you're wondering about the type of one of its arguments.  If you
look, you'll see that the type name in that argument (QKeyEvent) is a
link.  Click it, and you get to http://www.troll.no/qt/qkeyevent.html,
where you will find the information you need, including links to two
examples that use the class.

You can also see that QDialog::keyPressEvent() is a reimplementation
of QWidget::keyPressEvent(), the name of which is also a link.  Click
that link, and you get much more info about keyPressEvent() in
general.

--Arnt