finddialog.cpp Example File
dialogs/extension/finddialog.cpp
 
 
 #include <QtGui>
 #include "finddialog.h"
 FindDialog::FindDialog(QWidget *parent)
     : QDialog(parent)
 {
     label = new QLabel(tr("Find &what:"));
     lineEdit = new QLineEdit;
     label->setBuddy(lineEdit);
     caseCheckBox = new QCheckBox(tr("Match &case"));
     fromStartCheckBox = new QCheckBox(tr("Search from &start"));
     fromStartCheckBox->setChecked(true);
     findButton = new QPushButton(tr("&Find"));
     findButton->setDefault(true);
     moreButton = new QPushButton(tr("&More"));
     moreButton->setCheckable(true);
     moreButton->setAutoDefault(false);
     extension = new QWidget;
     wholeWordsCheckBox = new QCheckBox(tr("&Whole words"));
     backwardCheckBox = new QCheckBox(tr("Search &backward"));
     searchSelectionCheckBox = new QCheckBox(tr("Search se&lection"));
 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
     
     QMenu *menu = new QMenu(this);
     
     menu->addAction(tr("Find"));
     
     QAction *moreAction = menu->addAction(tr("More"));
     moreAction->setCheckable(true);
     
     QAction *optionAction = new QAction(tr("Options"), this);
     
     optionAction->setMenu(menu);
     optionAction->setSoftKeyRole(QAction::PositiveSoftKey);
     addAction(optionAction);
     
     connect(moreAction, SIGNAL(triggered(bool)), extension, SLOT(setVisible(bool)));
     
     QAction *backSoftKeyAction = new QAction(QString(tr("Exit")), this);
     backSoftKeyAction->setSoftKeyRole(QAction::NegativeSoftKey);
     
     connect(backSoftKeyAction, SIGNAL(triggered()), qApp, SLOT(quit()));
     addAction(backSoftKeyAction);
 #else
     buttonBox = new QDialogButtonBox(Qt::Vertical);
     buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
     buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);
     connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool)));
 #endif
     QVBoxLayout *extensionLayout = new QVBoxLayout;
     extensionLayout->setMargin(0);
     extensionLayout->addWidget(wholeWordsCheckBox);
     extensionLayout->addWidget(backwardCheckBox);
     extensionLayout->addWidget(searchSelectionCheckBox);
     extension->setLayout(extensionLayout);
     QHBoxLayout *topLeftLayout = new QHBoxLayout;
     topLeftLayout->addWidget(label);
     topLeftLayout->addWidget(lineEdit);
     QVBoxLayout *leftLayout = new QVBoxLayout;
     leftLayout->addLayout(topLeftLayout);
     leftLayout->addWidget(caseCheckBox);
     leftLayout->addWidget(fromStartCheckBox);
     QGridLayout *mainLayout = new QGridLayout;
 #if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR)
     mainLayout->setSizeConstraint(QLayout::SetFixedSize);
 #endif
     mainLayout->addLayout(leftLayout, 0, 0);
 #if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_SIMULATOR)
     mainLayout->addWidget(buttonBox, 0, 1);
 #endif
     mainLayout->addWidget(extension, 1, 0, 1, 2);
     mainLayout->setRowStretch(2, 1);
     setLayout(mainLayout);
     setWindowTitle(tr("Extension"));
     extension->hide();
 }