diff options
author | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-11 14:28:41 (GMT) |
---|---|---|
committer | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-11 14:28:41 (GMT) |
commit | a986d3f4948a782a8df71849464161bc4eff0766 (patch) | |
tree | 7586193d8bf0446c9f4361fd346bbcc8075bc7ad /examples/widgets | |
parent | d29dbdf82202942a59d12446d99751dc51050b93 (diff) | |
download | Qt-a986d3f4948a782a8df71849464161bc4eff0766.zip Qt-a986d3f4948a782a8df71849464161bc4eff0766.tar.gz Qt-a986d3f4948a782a8df71849464161bc4eff0766.tar.bz2 |
Updated example to tell which softkey was pressed
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/softkeys/softkeys.cpp | 24 | ||||
-rw-r--r-- | examples/widgets/softkeys/softkeys.h | 3 |
2 files changed, 19 insertions, 8 deletions
diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index edf38b9..b29be2b 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -3,6 +3,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + central = new QWidget(this); + setCentralWidget(central); + infoLabel = new QLabel(tr("Funky stuff in menu!")); + + layout = new QVBoxLayout; + layout->addWidget(infoLabel); + central->setLayout(layout); + central->setFocusPolicy(Qt::TabFocus); + fileMenu = menuBar()->addMenu(tr("&File")); openDialogAct = new QAction(tr("&Open Dialog"), this); addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); @@ -13,12 +22,6 @@ MainWindow::MainWindow(QWidget *parent) connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); - QWidget *central = new QWidget(this); - central->setLayout(new QVBoxLayout); -// central->setFocus(); - setCentralWidget(central); - QPushButton button1; -// QAction* menuAction = } MainWindow::~MainWindow() @@ -43,19 +46,24 @@ void MainWindow::addSoftKeys() QList<QAction*> softkeys; softkeys.append(ok); softkeys.append(cancel); - setSoftKeys(softkeys); + central->setSoftKeys(softkeys); + central->setFocus(); } void MainWindow::clearSoftKeys() { - setSoftKey(0); + central->setSoftKey(0); } void MainWindow::okPressed() { + infoLabel->setText(tr("OK pressed")); + central->setSoftKey(0); } void MainWindow::cancelPressed() { + infoLabel->setText(tr("Cancel pressed")); + central->setSoftKey(0); } diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index 2bc74ba..11db419 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -59,6 +59,9 @@ public: MainWindow(QWidget *parent = 0); ~MainWindow(); private: + QVBoxLayout *layout; + QWidget *central; + QLabel *infoLabel; QMenu* fileMenu; QAction* openDialogAct; QAction* addSoftKeysAct; |