关于Qt定时器的问题

DTApollo 2017-09-11 10:11:07
定时器内有多个函数
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(qtimeslot()));
timer->start(500); //定时器频率


这是定时器函数
其中有一个在定时器内的函数,他需要设置状态点,定时更新的是三个gif图,我用switch语句写的三个,放到timeslot里面就不变了,有人告诉我设置个三个状态点,每一个语句写一个状态点 ,有大哥知道怎么写吗??
switch语句:

void carInfo::ShowImage(QLabel* showLabel,int carmode)
{
QPixmap carmodeA(":/AB/charging");
QPixmap carmodeB(":/AB/cleaning");
QPixmap carmodeC(":/AB/manual");
QPixmap CarMode;
QSize t1=showLabel->size();
switch (carmode)
{
case'A':
CarMode = carmodeA.scaled(t1,Qt::KeepAspectRatio);
break;
case'B':
CarMode = carmodeB.scaled(t1,Qt::KeepAspectRatio);
break;
case'C':
CarMode = carmodeC.scaled(t1,Qt::KeepAspectRatio);
break;
default:
CarMode = carmodeA.scaled(t1,Qt::KeepAspectRatio);
break;
showLabel->setPixmap(CarMode);
break;
}

这个timeslot:
void carInfo::qtimeslot()
{
//test
ShowRechargeMileage++;
ShowLongitude++;
ShowLatitude++;

price= QString::number(ShowRechargeMileage);
pe.setColor(QPalette::WindowText, QColor(0x00,0xaa,0xff,0xff));
ui->label_3->setText(price);
ui->label_3->setPalette(pe);

price= QString::number(ShowLongitude);
pe.setColor(QPalette::WindowText, QColor(0x00,0xaa,0xff,0xff));
ui->label_21->setText(price);
ui->label_21->setPalette(pe);

price= QString::number(ShowLatitude);
pe.setColor(QPalette::WindowText, QColor(0x00,0xaa,0xff,0xff));
ui->label_19->setText(price);
ui->label_19->setPalette(pe);

ShowImage(ui->widget_2,ShowCarMode);//这就是那个展示的widget
...全文
549 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,216

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧