Guest User

Untitled

a guest
Jan 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. connect(button1, SIGNAL(clicked()), this, SLOT(markClicked(button1)));
  2.  
  3. void MainWindow::markClicked(QPushButton *button) { button->setText("Clicked"); }
  4.  
  5. QSignalMapper mapper;
  6. ...
  7. connect(button1, SIGNAL(clicked()), &mapper, SLOT(map()));
  8. mapper.setMapping(button1, button1); // not sure whether this is mandatory or not
  9. ...
  10. connect(&mapper, SIGNAL(mapped(QWidget*)), this, SLOT(markClicked(QWidget*)));
  11.  
  12. void MainWindow::markClicked(QWidget *widget) {
  13. QPushButton *button = qobject_cast<QPushButton*>(widget);
  14. button->setText("Clicked");
  15. }
Add Comment
Please, Sign In to add comment