Quote Originally Posted by zlatko
show a piece of code

p.s. too slowly

Hi,

I am including the code below.
Plz state why this happens?

Qt Code:
  1. FullCode::FullCode()
  2. : QWidget( 0, 0 )
  3. {
  4.  
  5. QGridLayout * g = new QGridLayout( this, 2, 2, 0);
  6. ............................
  7.  
  8. l = new QListBox( this );
  9. g->addWidget( l, 1, 1 );
  10. l->setMaximumSize(125,115);
  11. l->insertItem("M",-1);
  12. l->insertItem("Ma",-1);
  13.  
  14. ............................
  15. }
  16.  
  17.  
  18. FullCode::~FullCode()
  19. {
  20. delete bg;
  21. }
  22.  
  23.  
  24. void FullCode::keyPressEvent(QKeyEvent *event)
  25. {
  26. printf("Key Press.... %d\n", event->key());
  27. if(event->key() == Qt::Key_Up)
  28. {
  29. key_press = -1;
  30. }
  31. else if(event->key() == Qt::Key_Down)
  32. {
  33. key_press = 1;
  34. }
  35. else if(event->key() == Qt::Key_Right)
  36. {
  37. key_press = 2;
  38. }
  39. else if(event->key() == Qt::Key_Left)
  40. {
  41. key_press = -2;
  42. }
  43. else if(event->key() == Qt::Key_Return)
  44. {
  45. key_press = 3;
  46. }
  47. else {
  48. key_press = 0;
  49. }
  50. }
  51.  
  52. void QListBox::keyPressEvent(QKeyEvent *event)
  53. {
  54. FullCode ff;
  55. ff.keyPressEvent(event);
  56. }
To copy to clipboard, switch view to plain text mode 

Regards,

Mahe2310