关于Qt定时器的问题
定时器内有多个函数
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