1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#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;
webClient->setWidgetHint(mdiArea->viewport(), WebClient::StaticWidget);
*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);
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"
|