标签:pie val engine qstring load test 报错 san class
QtCharts模块可以用于绘制图表;
导入模块:
import QtCharts 2.2
例子:
import QtQuick 2.0 import QtCharts 2.2 ChartView { width: 400 height: 300 theme: ChartView.ChartThemeBrownSand antialiasing: true PieSeries { id: pieSeries PieSlice { label: "吃了的"; value: 94.9 } PieSlice { label: "还没吃的"; value: 5.1 } } }
注意: 仅仅这样,会报错。 还需要在main.cpp中引入#include <QApplication>(5.10默认是QCoreApplication,需要进行修改);如下:、
#include <QCoreApplication> #include <QApplication> #include <QQmlApplicationEngine> #include "test.h" int main(int argc, char *argv[]) { #if defined(Q_OS_WIN) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
同时,要在pro文件中添加 widgets,即
QT += quick widgets
qml: QtCharts模块的使用(基本配置)------<一>
标签:pie val engine qstring load test 报错 san class
原文地址:https://www.cnblogs.com/yinwei-space/p/8877979.html