Ejemplo n.º 1
0
//! [0]
DetailsDialog::DetailsDialog(const QString &title, QWidget *parent)
    : QDialog(parent)
{
    nameLabel = new QLabel(tr("Name:"));
    addressLabel = new QLabel(tr("Address:"));
    addressLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);

    nameEdit = new QLineEdit;
    addressEdit = new QTextEdit;

    offersCheckBox = new QCheckBox(tr("Send information about products and "
                                      "special offers"));

    setupItemsTable();

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
//! [0]

//! [1]
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameEdit, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0);
    mainLayout->addWidget(addressEdit, 1, 1);
    mainLayout->addWidget(itemsTable, 0, 2, 2, 1);
    mainLayout->addWidget(offersCheckBox, 2, 1, 1, 2);
    mainLayout->addWidget(buttonBox, 3, 0, 1, 3);
    setLayout(mainLayout);

    setWindowTitle(title);
}
Ejemplo n.º 2
0
//! [0]
DetailsDialog::DetailsDialog(const QString &title, QWidget *parent)
    : QDialog(parent)
{
    nameLabel = new QLabel(tr("Name:"));
    addressLabel = new QLabel(tr("Address:"));
    addressLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);

    nameEdit = new QLineEdit;
    addressEdit = new QTextEdit;

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    offersCheckBox = new QCheckBox(tr("Send information about\n"
                                      "products and special offers"));
#else
    offersCheckBox = new QCheckBox(tr("Send information about products and "
                                      "special offers"));
#endif

    setupItemsTable();

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
//! [0]

//! [1]
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    QWidget *widgetSubscriber = new QWidget;
    QGridLayout *subscriberLayout = new QGridLayout;
    subscriberLayout->addWidget(nameLabel, 0, 0);
    subscriberLayout->addWidget(nameEdit, 0, 1);
    subscriberLayout->addWidget(addressLabel, 1, 0);
    subscriberLayout->addWidget(addressEdit, 1, 1);
    subscriberLayout->addWidget(offersCheckBox, 2, 0, 1, 2);
    widgetSubscriber->setLayout(subscriberLayout);

    QWidget *widgetOrder = new QWidget;
    QVBoxLayout *orderLayout = new QVBoxLayout;
    orderLayout->addWidget(itemsTable);
    widgetOrder->setLayout(orderLayout);

    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(widgetSubscriber, "Subscriber");
    tabWidget->addTab(widgetOrder, "Order");

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(tabWidget);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);
#else
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(nameLabel, 0, 0);
    mainLayout->addWidget(nameEdit, 0, 1);
    mainLayout->addWidget(addressLabel, 1, 0);
    mainLayout->addWidget(addressEdit, 1, 1);
    mainLayout->addWidget(itemsTable, 0, 2, 2, 1);
    mainLayout->addWidget(offersCheckBox, 2, 1, 1, 2);
    mainLayout->addWidget(buttonBox, 3, 0, 1, 3);
    setLayout(mainLayout);
#endif

    setWindowTitle(title);
}