• 饼状图一


    参考文章:

    https://blog.csdn.net/xiezhongyuan07/article/details/82684118 

    效果图

    void Form::init()
    {
    
    
        QPieSeries *series = new QPieSeries();
    
    
        //饼图中间空心的大小
        series->setHoleSize(0.35);
    
    
        QPieSlice *slice1 = new QPieSlice(QString("111"), 1);
        slice1->setLabelVisible();
        slice1->setLabelPosition(QPieSlice::LabelOutside);
        slice1->setBrush(QColor(59,160,50));
    
    
        QPieSlice *slice2 = new QPieSlice(QString(""), 1);
        slice2->setLabel(QString("222"));
        slice2->setLabelVisible();
        slice2->setLabelPosition(QPieSlice::LabelInsideHorizontal);
        slice2->setBrush(QColor(59,160,100));
    
    
        QPieSlice *slice3 = new QPieSlice(QString(""), 1);
        slice3->setLabel(QString("333"));
        slice3->setLabelVisible();
        slice3->setLabelPosition(QPieSlice::LabelOutside);
        slice3->setBrush(QColor(59,160,150));
    
    
        QPieSlice *slice4 = new QPieSlice(QString(""), 1);
        slice4->setLabel(QString("444"));
        slice4->setLabelVisible();
        slice4->setLabelPosition(QPieSlice::LabelOutside);
        slice4->setBrush(QColor(255,0,0));
    
    
        series->append(slice1);
        series->append(slice2);
        series->append(slice3);
        series->append(slice4);
    
    
        //开始角度
        series->setPieStartAngle(100);
        //结束角度
        series->setPieEndAngle(300);
    
    
        QChartView *chartView = new QChartView();
        chartView->setRenderHint(QPainter::Antialiasing);
        //chartView->chart()->setTitle("DonutChart Example");
        chartView->chart()->addSeries(series);
        chartView->chart()->legend()->hide();
        //chartView->chart()->legend()->setAlignment(Qt::AlignRight);
    
    
        QVBoxLayout *vb = new QVBoxLayout(this);
    
    
        vb->addWidget(chartView);
        this->setLayout(vb);
    
    
        m_plabel = new QLabel(this);
        m_plabel->setFixedSize(40,40);
        m_plabel->setText("test");
        m_plabel->setStyleSheet(QString("background:transparent;font-family:Mircsoft Yahei;font-size:18px; color:#1564FF; font-weight:bold;"));
        m_plabel->move((this->width()-m_plabel->width())/2,
                                (this->height()-m_plabel->height())/2);
    }
    
    
    void Form::resizeEvent(QResizeEvent* event)
    {
        m_plabel->move((this->width()-m_plabel->width())/2,
                                (this->height()-m_plabel->height())/2);
    
    
        return QWidget::resizeEvent(event);
    
    
    }
  • 相关阅读:
    与(&,&&)和或(|,||)的区别
    vue笔记(更新中)
    echarts实现心脏图的滚动三种实现方法
    生成四则运算
    软件工程第四次作业
    软件工程第三次作业
    软件工程第二次作业
    软件工程第一次作业
    前端优化
    关于事件监听
  • 原文地址:https://www.cnblogs.com/zhangxuan/p/10148985.html
Copyright © 2020-2023  润新知