Use QSignalMapper.
Qt Code:
  1. QSignalMapper *sm = new QSignalMapper( this );
  2.  
  3. // create buttons
  4. QPushButton *b1 = new QPushButton( "A", this );
  5. connect( b1, SIGNAL(clicked()), sm, SLOT(map()) );
  6. ...
  7.  
  8. // set mapping
  9. sm->setMapping( b1, "A" );
  10. ...
  11.  
  12. connect( sm, SIGNAL(mapped(QString)), this, SLOT(keyboard(QString)) );
  13.  
  14. slot keyboard( const QString &key )
  15. {
  16. // do something with key
  17. ...
  18.  
  19. // restart timer
  20. ...
  21. }
To copy to clipboard, switch view to plain text mode