diff options
Diffstat (limited to 'examples/widgets/maemovibration/buttonwidget.cpp')
-rw-r--r-- | examples/widgets/maemovibration/buttonwidget.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/examples/widgets/maemovibration/buttonwidget.cpp b/examples/widgets/maemovibration/buttonwidget.cpp new file mode 100644 index 0000000..a723c31 --- /dev/null +++ b/examples/widgets/maemovibration/buttonwidget.cpp @@ -0,0 +1,26 @@ +#include "buttonwidget.h" +#include <QSignalMapper> +#include <QGridLayout> +#include <QPushButton> + +//! [0] +ButtonWidget::ButtonWidget(QStringList texts, QWidget *parent) + : QWidget(parent) +{ + signalMapper = new QSignalMapper(this); + + QGridLayout *gridLayout = new QGridLayout; + for (int i = 0; i < texts.size(); ++i) { + QPushButton *button = new QPushButton(texts[i]); + connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); + signalMapper->setMapping(button, texts[i]); + gridLayout->addWidget(button, i / 2, i % 2); + } + + connect(signalMapper, SIGNAL(mapped(const QString &)), + this, SIGNAL(clicked(const QString &))); + + setLayout(gridLayout); +} +//! [0] + |