From: http://qt-project.org/doc/qt-4.8/dec...r1-basics.html
import Charts 1.0
import QtQuick 1.0
Item {
width: 300; height: 200
PieChart {
id: aPieChart
anchors.centerIn: parent
width: 100; height: 100
name: "A simple pie chart"
color: "red"
}
Text {
anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
text: aPieChart.name
}
}
import Charts 1.0
import QtQuick 1.0
Item {
width: 300; height: 200
PieChart {
id: aPieChart
anchors.centerIn: parent
width: 100; height: 100
name: "A simple pie chart"
color: "red"
}
Text {
anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
text: aPieChart.name
}
}
To copy to clipboard, switch view to plain text mode
#include "piechart.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
int main(int argc, char *argv[])
{
qmlRegisterType<PieChart> ("Charts", 1, 0, "PieChart");
QDeclarativeView view;
view.
setSource (QUrl::fromLocalFile("app.qml"));
view.show ();
return app.exec();
}
#include "piechart.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app (argc, argv);
qmlRegisterType<PieChart> ("Charts", 1, 0, "PieChart");
QDeclarativeView view;
view.setSource (QUrl::fromLocalFile("app.qml"));
view.show ();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Question:
The QML file contains:
import Charts 1.0
That must be some special module for PieCharts drawing.
How do I know what module should be imported for drawing "lines", "circles", etc?
and the main.cpp contains:
qmlRegisterType<PieChart> ("Charts", 1, 0, "PieChart");
From: http://qt-project.org/doc/qt-5.0/qtq...mlRegisterType
This template function registers the C++ type in the QML system with the name qmlName,
in the library imported from uri having the version number composed from versionMajor and versionMinor.
What is it about 'uri'?
I couldn't understand that argument, Please explain.
For example instead of Piechart, if I draw a line, then what would be uri argument?
Bookmarks