Hi wysota!
first of all, I use whole labels because of the convinence of setting the picture inside Qt designer.
second, here's my code.
where i call the function blinkLabel if I don't pass parameters.
void Mainframe::on_canbus_RevBoolData(bool temp)
{
// TODO
label->hide();
label_2->hide();
if(temp)
{
label_2->show();
label->hide();
}
else
{
/**********************************************/
connect(timer, SIGNAL(timeout()), this, SLOT(blinkLabel1_2()));
timer->start(1000);
this->blinkLabel1_2();
/**********************************************/
}
}
void Mainframe::blinkLabel1_2()
{
static bool on = false;
if(on)
{
label->show();
label_2->hide();
on = false;
}
else
{
label_2->show();
label->hide();
on = true;
}
}
void Mainframe::on_canbus_RevBoolData(bool temp)
{
// TODO
label->hide();
label_2->hide();
if(temp)
{
label_2->show();
label->hide();
}
else
{
/**********************************************/
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(blinkLabel1_2()));
timer->start(1000);
this->blinkLabel1_2();
/**********************************************/
}
}
void Mainframe::blinkLabel1_2()
{
static bool on = false;
if(on)
{
label->show();
label_2->hide();
on = false;
}
else
{
label_2->show();
label->hide();
on = true;
}
}
To copy to clipboard, switch view to plain text mode
if I pass in parameters (from what u suggested)
void Mainframe::on_canbus_RevBoolData(bool temp)
{
// TODO
label->hide();
label_2->hide();
if(temp)
{
label_2->show();
label->hide();
}
else
{
/**********************************************/
connect(timer, SIGNAL(timeout()), this, SLOT(blinkLabel1_2(label, label_2)));
timer->start(1000);
this->blinkLabel1_2(label, label_2);
/**********************************************/
}
}
{
static bool on = false;
if(on)
{
l1->show();
l2->hide();
on = false;
}
else
{
l2->show();
l1->hide();
on = true;
}
}
void Mainframe::on_canbus_RevBoolData(bool temp)
{
// TODO
label->hide();
label_2->hide();
if(temp)
{
label_2->show();
label->hide();
}
else
{
/**********************************************/
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(blinkLabel1_2(label, label_2)));
timer->start(1000);
this->blinkLabel1_2(label, label_2);
/**********************************************/
}
}
void Mainframe::blinkLabel1_2(QLabel* l1, QLabel* l2)
{
static bool on = false;
if(on)
{
l1->show();
l2->hide();
on = false;
}
else
{
l2->show();
l1->hide();
on = true;
}
}
To copy to clipboard, switch view to plain text mode
no errors encountered, but I have no idea now why it doesn't blink...
Thanks for yr reply wysota!
Bookmarks