12 #include <QQuickWidget> 13 #include <QQmlContext> 20 QQuickWidget* pv =
new QQuickWidget(QUrl(
"qrc:/main.qml"));
22 QVBoxLayout* pvbx =
new QVBoxLayout;
26 QQmlContext* pcon = pv->rootContext();
28 for (
int i = 0; i < 100; ++i) {
29 lst <<
"Item" + QString::number(i);
31 QStringListModel* pmodel =
new QStringListModel(
this);
32 pmodel->setStringList(lst);
34 pcon->setContextProperty(
"myModel", pmodel);
35 pcon->setContextProperty(
"myText",
"It's my text!");
36 pcon->setContextProperty(
"myColor", QColor(Qt::yellow));
37 pcon->setContextProperty(
"myWidget",
this);
43 QMessageBox::information(0,
"Message",
"It's my message");