当前位置: 首页 > news >正文

杭州网站建设找思创网络做网站语言服务器 空间

杭州网站建设找思创网络,做网站语言服务器 空间,网站内容页相关性怎么做,公司建设网站需要什么资质界面样式 项目开发流程 1.通过QtCreator创建一个Qt Quick插件,插件命名为CarPanMod; 2.通过QtCreator创建一个Qt Quick Application,命名为QmlPro; 3.在插件CarPanMod中实现条形图,折线图和饼状图的绘制; 4.在应用程序QmlPro中,添加插件的导入路径; 5.在应用程序中,通过i…界面样式 项目开发流程 1.通过QtCreator创建一个Qt Quick插件,插件命名为CarPanMod; 2.通过QtCreator创建一个Qt Quick Application,命名为QmlPro; 3.在插件CarPanMod中实现条形图,折线图和饼状图的绘制; 4.在应用程序QmlPro中,添加插件的导入路径; 5.在应用程序中,通过import CarPanMod 1.0导入Qml文件即可访问插件中实现的各种图表. C++代码实现 条形图实现 barchartitem.h #ifndef BARCHARTITEM_H #define BARCHARTITEM_H#include QQuickPaintedItem #include QVector #include QPropertyAnimationclass BarChartItem : public QQuickPaintedItem {Q_OBJECTQ_PROPERTY(QVariantList data READ data WRITE setData NOTIFY dataChanged)Q_PROPERTY(QStringList labels READ labels WRITE setLabels NOTIFY labelsChanged)Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)Q_PROPERTY(QColor barColor READ barColor WRITE setBarColor NOTIFY barColorChanged)public:explicit BarChartItem(QQuickItem *parent = nullptr);void paint(QPainter *painter) override;// 属性访问器QVariantList data() const;void setData(const QVariantList data);QStringList labels() const;void setLabels(const QStringList labels);QString title() const;void setTitle(const QString title);QColor barColor() const;void setBarColor(const QColor color);protected:void hoverMoveEvent(QHoverEvent *event) override;void hoverLeaveEvent(QHoverEvent *event) override;signals:void dataChanged();void labelsChanged();void titleChanged();void barColorChanged();private:struct BarItem {QRectF rect;qreal value;bool highlighted = false;QColor color;};void updateChartLayout();void animateBar(int index, bool highlight);QVariantList m_data = {6324, 6793, 7476, 7892,8734, 9337, 9860, 10485,11230, 12100};QStringList m_labels = {"2014", "2015", "2016", "2017","2018", "2019", "2020", "2021","2022", "2023"};QString m_title = "全国平均房价(元/㎡)";QColor m_barColor = QColor("#3498db");QVectorBarItem m_bars;int m_hoveredIndex = -1;QPropertyAnimation *m_animation; };#endif // BARCHARTITEM_Hbarchartitem.cpp #include "barchartitem.h"#include QPainter #include QFontMetricsBarChartItem::BarChartItem(QQuickItem *parent): QQuickPaintedItem(parent), m_animation(new QPropertyAnimation(this)) {setAcceptHoverEvents(true);setFlag(ItemHasContents, true);setAntialiasing(true);m_animation-setPropertyName("barColor");m_animation-setDuration(300); }void BarChartItem::paint(QPainter *painter) {painter-setRenderHint(QPainter::Antialiasing);// 绘制背景 // painter-fillRect(boundingRect(), QColor("#f5f5f5"));painter-fillRect(boundingRect(),QColor("transparent"));// 计算布局updateChartLayout();// 绘制标题QFont titleFont = painter-font();titleFont.setPointSize(14);titleFont.setBold(true);painter-setFont(titleFont);painter-setPen(Qt::black);painter-drawText(QRectF(0, 10, width(), 30), Qt::AlignCenter, m_title);// 绘制坐标轴const qreal axisMargin = 50;const QLineF xAxis(axisMargin, height() - axisMargin, width() - axisMargin, height() - axisMargin);const QLineF yAxis(axisMargin, axisMargin, axisMargin, height() - axisMargin);painter-setPen(QPen(Qt::black, 2));painter-drawLine(xAxis);painter-drawLine(yAxis);// 绘制刻度QFont tickFont = painter-font();tickFont.setPointSize(8);painter-setFont(tickFont);// Y轴刻度qreal maxValue = 0;for (const auto v : m_data) {maxValue = qMax(maxValue, v.toReal());}const int yTicks = 5;for (int i = 0; i = yTicks; ++i) {qreal y = yAxis.y1() - (yAxis.length() / yTicks) * i;qreal value = maxValue / yTicks * i;painter-drawLine(QPointF(yAxis.x1() - 5, y), QPointF(yAxis.x1(), y));painter-drawText(QRectF(0, y - 10, yAxis.x1() - 10, 20),Qt::AlignRight | Qt::AlignVCenter,QString::number(value, 'f', 0));}// 绘制条形for (int i = 0; i m_bars.size(); ++i) {const BarItem bar = m_bars[i];QColor color = bar.highlighted ? bar.color.lighter(130) : bar.color;// 条形阴影painter-setPen(Qt::NoPen);painter-setBrush(QColor(0, 0, 0, 50));painter-drawRect(bar.rect.adjusted(3, 3, 3, 3));// 条形主体painter-setBrush(color);painter-setPen(QPen(Qt::white, 1));painter-drawRect(bar.rect);// 数值标签painter-setPen(Qt::black);painter-drawText(QRectF(bar.rect.x(), bar.rect.y() - 25,bar.rect.width(), 20),Qt::AlignCenter,QString::number(bar.value, 'f', 0));// X轴标签if (i m_labels.size()) {painter-drawText(QRectF(bar.rect.x(), height() - axisMargin + 5,bar.rect.width(), 20),Qt::AlignCenter, m_labels[i]);}}#if 0// 绘制图例if (!m_labels.isEmpty()) {QRectF legendRect(width() - 150, 40, 140, 30);painter-setBrush(m_barColor);painter-drawRect(legendRect.adjusted(0, 0, -110, 0));painter-drawText(legendRect, Qt::AlignRight | Qt::AlignVCenter, "房价趋势");} #endif }QVariantList BarChartItem::data() const {return m_data; }void BarChartItem::setData(const QVariantList data) {if(m_data != data){m_data = data;update();emit dataChanged();} }QStringList BarChartItem::labels() const {return m_labels; }void BarChartItem::setLabels(const QStringList labels) {if (m_labels != labels) {m_labels = labels;update();emit labelsChanged();} }QString BarChartItem::title() const {return m_title; }void BarChartItem::setTitle(const QString title) {if(m_title != title){m_title = title;update();emit titleChanged();} }QColor BarChartItem::barColor() const {return m_barColor; }void BarChartItem::setBarColor(const QColor color) {if(m_barColor != color){m_barColor = color;update();emit barColorChanged();} }void BarChartItem::updateChartLayout() {if (m_data.isEmpty()) return;const qreal axisMargin = 50;const qreal chartWidth = width() - axisMargin * 2;const qreal chartHeight = height() - axisMargin * 2;const qreal barSpacing = 10;const qreal barWidth = (chartWidth - barSpacing * (m_data.size() - 1)) / m_data.size();qreal maxValue = 0;for (const auto v : m_data) {maxValue = qMax(maxValue, v.toReal());}m_bars.resize(m_data.size());for (int i = 0; i m_data.size(); ++i) {qreal value = m_data[i].toReal();qreal barHeight = (value / maxValue) * chartHeight;m_bars[i].rect = QRectF(axisMargin + i * (barWidth + barSpacing),height() - axisMargin - barHeight,barWidth,barHeight);m_bars[i].value = value;m_bars[i].color = m_barColor;m_bars[i].highlighted = (i == m_hoveredIndex);} }void BarChartItem::animateBar(int index, bool highlight) {if (index 0 || index = m_bars.size()) return;m_animation-setStartValue(m_bars[index].color);m_animation-setEndValue(highlight ? m_barColor.lighter(130) : m_barColor);m_animation-setDuration(1000);m_animation-start(); }void BarChartItem::hoverMoveEvent(QHoverEvent *event) {const QPointF pos = event-pos();for (int i = 0; i m_bars.size(); ++i) {if (m_bars[i].rect.contains(pos)) {if (m_hoveredIndex != i) {m_hoveredIndex = i; // animateBar(i, true);update();}return;}}if (m_hoveredIndex != -1) {m_hoveredIndex = -1;update();} }void BarChartItem::hoverLeaveEvent(QHoverEvent *) {if (m_hoveredIndex != -1) { // animateBar(m_hoveredIndex, false);m_hoveredIndex = -1;update();} } 折线图实现 linechartitem.h
http://www.pierceye.com/news/441786/

相关文章:

  • 软件工程师证书报考网站dede系统做的网站如何调用cu3er官网flash 3d焦点图
  • 创意策划网站用照片做视频的网站好
  • 包头市建设局网站国内做的好的电商网站有哪些方面
  • 群辉服务器做网站营销自动化系统
  • 公司设计网站推荐做网站用注册公司吗
  • 机房建设 网站建设工程标准在线网站
  • 网站建设是属于软件开发费吗Wordpress有用么
  • 上海 网站备案商务网站规划与建设课程设计
  • 网站 首页 栏目 内容网业设计
  • 用vs与dw做网站什么做电子书下载网站好
  • 网站建设发布教程网页设计师收费标准
  • 徐州哪里做网站好农林网站建设公司
  • 可以做直播卖产品的网站专业产品画册设计公司
  • wp网站开发个人小程序开发流程
  • 网站制作报价大约重庆招聘网站建设
  • 网站开发 资质网站开发价格评估
  • 泰州网站关键词优化谷歌建站
  • 门户网站风格企业网站建设的成本
  • 一站式外贸综合服务平台社区网站推广方案
  • 宁波网络公司网站建设项目怎么破解别人做的付费网站
  • 做创意小视频的网站centos 7.4 wordpress
  • 免费建立单位的网站适合个人做的跨境电商
  • 沈阳军成网站建设17网站一起做网店
  • 哪些cms做同城网站比较好上海建设工程协会网站
  • 潍坊企业自助建站系统seo博客网站
  • 做啤酒最全的网站鱼台县建设局网站
  • 网站开发转行进入衍生领域wordpress qaengine
  • 公司内部网站模板快速建网站的软件
  • 被骗去国外做网站网站推广网站的运营推广方案
  • 北京汽车业务网站开发公司桂林旅游攻略必去景点