#include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /** We'll wire those signals */ connect(this, SIGNAL(signal()), this, SLOT(signalStringSlot())); connect(this, SIGNAL(signalString(const QString&)), this, SLOT(slotString(const QString&))); /** So we request timer to shoot a signal to a slot() after a second. */ QTimer::singleShot(1000, this, SLOT(slot())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::signalStringSlot() { emit signalString(QString("Look, I can send strings through signal!")); } void MainWindow::slot() { QMessageBox::information(this, "SLOT!", "Yay! SLOT reached!"); emit signal(); } void MainWindow::slotString(const QString& string) { QMessageBox::information(this, "SLOT String!", string); }