zoukankan      html  css  js  c++  java
  • Qt Qwdget 汽车仪表知识点拆解3 进度条编写

    先贴上效果图,注意,没有写逻辑,都是乱动的


    这篇我来说说左侧的这个进度条的实现原理,其实更简单,哈哈哈

    有一个大的widget,根据素材,我放了10个label

    剩下的就是写一个函数,根据数据的不同,实时控制这10个label的显示,

    实现代码

    void Widget::show_Lline(int num)
    {
    
        switch (num) {
        case 0:
        {
            ui->label_lline_1->hide();
            ui->label_lline_2->hide();
            ui->label_lline_3->hide();
            ui->label_lline_4->hide();
            ui->label_lline_5->hide();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 1:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->hide();
            ui->label_lline_3->hide();
            ui->label_lline_4->hide();
            ui->label_lline_5->hide();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 2:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->hide();
            ui->label_lline_4->hide();
            ui->label_lline_5->hide();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 3:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->hide();
            ui->label_lline_5->hide();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 4:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->hide();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 5:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->hide();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 6:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->show();
            ui->label_lline_7->hide();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 7:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->show();
            ui->label_lline_7->show();
            ui->label_lline_8->hide();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 8:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->show();
            ui->label_lline_7->show();
            ui->label_lline_8->show();
            ui->label_lline_9->hide();
            ui->label_lline_10->hide();
            break;
        }
        case 9:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->show();
            ui->label_lline_7->show();
            ui->label_lline_8->show();
            ui->label_lline_9->show();
            ui->label_lline_10->hide();
            break;
        }
        case 10:
        {
            ui->label_lline_1->show();
            ui->label_lline_2->show();
            ui->label_lline_3->show();
            ui->label_lline_4->show();
            ui->label_lline_5->show();
            ui->label_lline_6->show();
            ui->label_lline_7->show();
            ui->label_lline_8->show();
            ui->label_lline_9->show();
            ui->label_lline_10->show();
            break;
        }
        default:
            break;
        }
    }


    这样,就可以了

  • 相关阅读:
    opencv ellipse
    Spring.NET实用技巧4——NHibernate分布式事务(下)
    Spring.NET企业架构实践之 Nhibernate + WCF + ASP.NET MVC + NVelocity 对PetShop4.0重构(二)——领域模型
    Spring.NET实用技巧3——NHibernate分布式事务(上)
    Spring.NET企业架构实践之 NHibernate + Spring.NET + WCF + Windows服务 + Silverlight 中小企业应用架构完整Demo
    关于nunit调试VS2010中的4.0程序集的问题
    Spring.NET企业架构实践之 Nhibernate + WCF + ASP.NET MVC + NVelocity 对PetShop4.0重构(三)——持久层
    Spring.NET实用技巧5——WCF环境下的NHibernate分布式事务
    有多少可爱IT精英,他们的爱情屡屡“挨踢”
    Spring.NET 1.3.1 正式版已发布
  • 原文地址:https://www.cnblogs.com/DreamDog/p/9160051.html
Copyright © 2011-2022 走看看