diff options
| author | Morten Sorvig <msorvig@trolltech.com> | 2009-09-17 17:48:18 +0200 |
|---|---|---|
| committer | Morten Sorvig <msorvig@trolltech.com> | 2009-09-17 17:48:18 +0200 |
| commit | f6cbfdc020a3349f850f437019669b0d30c45cba (patch) | |
| tree | 776b53ed348e069cad647a17474dac0e22a30a97 | |
| parent | 9d23388dd50780fa1c33324bbbab1b60b853f83a (diff) | |
Make the line edits example use QMdiArea.
| -rw-r--r-- | demos/lineedit/lineedit.pro | 2 | ||||
| -rwxr-xr-x | demos/lineedit/main.cpp | 83 |
2 files changed, 56 insertions, 29 deletions
diff --git a/demos/lineedit/lineedit.pro b/demos/lineedit/lineedit.pro index 7468d6c..bd9f144 100644 --- a/demos/lineedit/lineedit.pro +++ b/demos/lineedit/lineedit.pro @@ -1,5 +1,5 @@ include (../../qt-web.pri) -DEFINES += QT_WEBCLIENT_DEBUG +#DEFINES += QT_WEBCLIENT_DEBUG TEMPLATE = app TARGET = DEPENDPATH += . diff --git a/demos/lineedit/main.cpp b/demos/lineedit/main.cpp index 685388c..ad804e3 100755 --- a/demos/lineedit/main.cpp +++ b/demos/lineedit/main.cpp @@ -1,39 +1,66 @@ #include <QtGui> #include <webclient.h> +WebClient *webClient; + +class QRcServer : public QObject +{ + Q_OBJECT + public slots: + void instantiateUi(QWidget **root, Session *session) + { + Q_UNUSED(session); + + QMdiArea *mdiArea = new QMdiArea; + *root = mdiArea; + + QWidget *mainWidget = new QWidget(); + QMdiSubWindow *mdiSub = mdiArea->addSubWindow(mainWidget); + webClient->setWidgetHint(mdiSub, WebClient::StaticWidget); + + QVBoxLayout *mainLayout = new QVBoxLayout(); + + QString text = "<b>Line edits example: </b> The content of the native " + "line edits is synchronized server-side"; + mainLayout->addWidget(new QLabel(text)); + + QHBoxLayout *layout = new QHBoxLayout(); + + QLineEdit *lineEdit1 = new QLineEdit(); + layout->addWidget(lineEdit1); + + QLineEdit *lineEdit2 = new QLineEdit(); + layout->addWidget(lineEdit2); + + QObject::connect(lineEdit1, SIGNAL(textEdited(const QString &)), lineEdit2, SLOT(setText(const QString &))); + QObject::connect(lineEdit2, SIGNAL(textEdited(const QString &)), lineEdit1, SLOT(setText(const QString &))); + + QPushButton *pushButton = new QPushButton("Clear Text"); + layout->addWidget(pushButton); + QObject::connect(pushButton, SIGNAL(clicked()), lineEdit1, SLOT(clear())); + QObject::connect(pushButton, SIGNAL(clicked()), lineEdit2, SLOT(clear())); + + mainLayout->addLayout(layout); + mainWidget->setLayout(mainLayout); + } +}; int main(int argc, char **argv) { QApplication app(argc, argv); - - QWidget *mainWidget = new QWidget(); - QVBoxLayout *mainLayout = new QVBoxLayout(); - QString text = "<b>Line edits example: </b> The content of the native" - "line edits is synchronized server-side"; - mainLayout->addWidget(new QLabel(text)); - QHBoxLayout *layout = new QHBoxLayout(); - - QLineEdit *lineEdit1 = new QLineEdit(); - layout->addWidget(lineEdit1); - - QLineEdit *lineEdit2 = new QLineEdit(); - layout->addWidget(lineEdit2); - - QObject::connect(lineEdit1, SIGNAL(textEdited(const QString &)), lineEdit2, SLOT(setText(const QString &))); - QObject::connect(lineEdit2, SIGNAL(textEdited(const QString &)), lineEdit1, SLOT(setText(const QString &))); - - QPushButton *pushButton = new QPushButton("Clear Text"); - layout->addWidget(pushButton); - QObject::connect(pushButton, SIGNAL(clicked()), lineEdit1, SLOT(clear())); - QObject::connect(pushButton, SIGNAL(clicked()), lineEdit2, SLOT(clear())); - - mainLayout->addLayout(layout); - mainWidget->setLayout(mainLayout); - - WebClient server; - server.setRootWidget(mainWidget); - + webClient = new WebClient; + // webClient.setActiveSessionLimit(100); + + QRcServer qrcServer; + + QRcServer object; + QObject::connect(webClient, SIGNAL(newSession(QWidget **, Session *)), + &qrcServer, SLOT(instantiateUi(QWidget **, Session *))); + return app.exec(); } +#include "main.moc" + + |
