zoukankan      html  css  js  c++  java
  • qml: QtChart横纵轴label设置;

    在qml中,使用ChartView作为图表展示区域, 但是并没有给定接口用来设置xlabel,ylabel。 

    没得办法,只能采用笨方案: (我的方法如下)

    import QtQuick 2.0
    import MaterialUI 1.0
    import  QtCharts 2.0  as  CHARTS
     CHARTS.ChartView{
        id: chart;
        property alias xlabel: xlabel.text;
        property alias ylabel: ylabel.text;
        property int rotation: -90;
        Rectangle{
            id:  xlabelArea;
            height: chart.margins.bottom;
            anchors{
                left: chart.left;
                right:chart.right;
                bottom: chart.bottom;
            }
    
            Text{id: xlabel; anchors.centerIn:  parent;}
        }
    
        Rectangle{
            id: ylabelArea;
             chart.margins.left;
            anchors{
                left: chart.left;
                top: chart.top;
                bottom: chart.bottom;
            }
            Text{
                id: ylabel;anchors.centerIn: parent; rotation: -90;
            }
        }
    }

    该方法需要了解两个知识点:

    1)  文字旋转;        ------------     Item自带rotation属性,可以实现任意角度的旋转;

    2)  margin大小(ChartView与图表之间的间隔);   ---------------------  QChartView与Chart之间的大小可以从margins属性中获取;

    注:  若哪位知道其他实现的方法,望能不吝相告!

  • 相关阅读:
    3. 操作系统优化
    Linux 目录
    2. 系统的目录结构
    1. 系统管理以及操作命令
    7. 流程控制之for循环
    6. 流程控制之while循环
    我的第一篇博客园随笔
    H5自带进度条&滑块
    DIV水平方向居中的几种方法
    vue入门--简单嵌套路由的一个路径小问题
  • 原文地址:https://www.cnblogs.com/yinwei-space/p/9021045.html
Copyright © 2011-2022 走看看