15 int main(
int argc,
char** argv)
17 QApplication app(argc, argv);
18 QWidget* pwgt =
new QWidget;
20 QLineEdit* ptxt =
new QLineEdit;
21 ptxt->setObjectName(
"lineedit");
23 QLabel* plbl1 =
new QLabel(
"1");
24 plbl1->setObjectName(
"label1");
26 QLabel* plbl2 =
new QLabel(
"2");
27 plbl2->setObjectName(
"label2");
29 QLabel* plbl3 =
new QLabel(
"3");
30 plbl3->setObjectName(
"label3");
32 QLabel* plbl4 =
new QLabel(
"4");
33 plbl4->setObjectName(
"label4");
36 QVBoxLayout* pvbxLayout =
new QVBoxLayout;
37 pvbxLayout->addWidget(ptxt);
38 pvbxLayout->addWidget(plbl1);
39 pvbxLayout->addWidget(plbl2);
40 pvbxLayout->addWidget(plbl3);
41 pvbxLayout->addWidget(plbl4);
42 pwgt->setLayout(pvbxLayout);
48 QFile file(
":/script.js");
49 if (file.open(QFile::ReadOnly)) {
50 QJSValue sw = se.newQObject(pwgt);
52 se.globalObject().setProperty(
"wgt", sw);
54 QList<QObject*> lst = pwgt->findChildren<QObject*>();
55 foreach(QObject* pobj, lst) {
56 sw = se.newQObject(pobj);
57 se.globalObject().setProperty(pobj->objectName(), sw);
61 se.evaluate(QLatin1String(file.readAll()));
62 if (result.isError()) {
63 QMessageBox::critical(0,
71 QMessageBox::critical(0,
73 "Can not open the script file",
int main(int argc, char **argv)