Hi to all I’m new to programming and I read a C++ book and now I’m exploring QT and I’m trying to write a simple code just to learn how things work and I’m having errors in this code can any 1 guide me to what will fix this code and make it work

Thanks to all


Ok this is what the code dose:

If you press x you will get a message box with a label that says "Hello XXQt!"
And if you press y you will get a message that says "Hello YYQt!"
And then exits

This is the errors that I get when running it:

1- C:/Documents and Settings/User/Desktop/testcase/main.cpp:13: error: a function-definition is not allowed here before '{' token

2- C:/Documents and Settings/User/Desktop/testcase/main.cpp:29: error: expected '}' at end of input

3- C:/Documents and Settings/User/Desktop/testcase/main.cpp:29: warning: no return statement in function returning non-void



#include <QApplication>
#include <QLabel>
#include <QKeyEvent>
#include <QWidget>


int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//QKeyPressEvent *keyprs = new QKeyPressEvent *k;
void QWidget::keyPressEvent ( QKeyEvent *k )

{
switch ((k->ascii()) ) {
case 'x':
QLabel *label = new QLabel("Hello XXQt!");
label->show();
break;
case 'y':
QLabel *label = new QLabel("Hello YYQt!");
label->show();
default:
QApplication::exit();
break;
}
}

return app.exec();
}
[/B][/B][/B]