import QtQuick 2.0
import QtQuick.Controls 1.2
Rectangle {
height: 300
width: 600
//![0]
ListView {
width: 200; height: 250
model: myModel
delegate: Text { text: "Animal: " + type + ", " + size }
}
//![0]
TableView {
y:150
width: 600
model: myModel
TableViewColumn {
role: "type"
title: "Type"
width: 200
}
TableViewColumn {
role: "size"
title: "Size"
width: 200
}
}
}
import QtQuick 2.0
import QtQuick.Controls 1.2
Rectangle {
height: 300
width: 600
//![0]
ListView {
width: 200; height: 250
model: myModel
delegate: Text { text: "Animal: " + type + ", " + size }
}
//![0]
TableView {
y:150
width: 600
model: myModel
TableViewColumn {
role: "type"
title: "Type"
width: 200
}
TableViewColumn {
role: "size"
title: "Size"
width: 200
}
}
}
To copy to clipboard, switch view to plain text mode
QGuiApplication app(argc, argv);
AnimalModel model;
model.addAnimal(Animal("Wolf", "Medium"));
model.addAnimal(Animal("Polar bear", "Large"));
model.addAnimal(Animal("Quoll", "Small"));
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
QQmlContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
//![0]
view.
setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
QGuiApplication app(argc, argv);
AnimalModel model;
model.addAnimal(Animal("Wolf", "Medium"));
model.addAnimal(Animal("Polar bear", "Large"));
model.addAnimal(Animal("Quoll", "Small"));
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
QQmlContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
//![0]
view.setSource(QUrl("qrc:view.qml"));
view.show();
return app.exec();
To copy to clipboard, switch view to plain text mode
QQmlApplicationEngine *engine = new QQmlApplicationEngine;
ComboModel combo;
lst << "Geelikynnet" << "Ripset" << "Kampaus" << "Tatuointi" << "Kulmat";
combo.setComboList(lst);
LineModel rokmodel;
rokmodel.addLine(Line("Kulmat", "155,00", "Heidi"));
rokmodel.addLine(Line("Tatuointi", "255,00", "Heidi"));
rokmodel.addLine(Line("Kynnet", "55,00", "Ann-Marii"));
rokmodel.addLine(Line("Ripset", "5,00", "Ann-Marii"));
QQmlContext *ctxt = engine->rootContext();
ctxt
->setContextProperty
("rokmodel",
QVariant::fromValue(&rokmodel
));
ctxt
->setContextProperty
("myModel",
QVariant::fromValue(combo.
comboList()));
ctxt->setContextProperty("comboModel", &combo);
ctxt->setContextProperty("product", this);
engine
->load
(QUrl(QStringLiteral
("qrc:/main.qml")));
QObject::connect(engine
->rootObjects
().
takeFirst(),
SIGNAL(listSignal
(QString)),
this,
SLOT(listSignal
(QString)));
QQmlApplicationEngine *engine = new QQmlApplicationEngine;
ComboModel combo;
QStringList lst;
lst << "Geelikynnet" << "Ripset" << "Kampaus" << "Tatuointi" << "Kulmat";
combo.setComboList(lst);
LineModel rokmodel;
rokmodel.addLine(Line("Kulmat", "155,00", "Heidi"));
rokmodel.addLine(Line("Tatuointi", "255,00", "Heidi"));
rokmodel.addLine(Line("Kynnet", "55,00", "Ann-Marii"));
rokmodel.addLine(Line("Ripset", "5,00", "Ann-Marii"));
QQmlContext *ctxt = engine->rootContext();
ctxt->setContextProperty("rokmodel", QVariant::fromValue(&rokmodel));
ctxt->setContextProperty("myModel", QVariant::fromValue(combo.comboList()));
ctxt->setContextProperty("comboModel", &combo);
ctxt->setContextProperty("product", this);
engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
QObject::connect(engine->rootObjects().takeFirst(), SIGNAL(qmlSignal(QString, QString)), this, SLOT(buttonPressed(QString, QString)));
QObject::connect(engine->rootObjects().takeFirst(), SIGNAL(listSignal(QString)), this, SLOT(listSignal(QString)));
To copy to clipboard, switch view to plain text mode
Bookmarks