RThaden
8th July 2008, 23:22
Hi all,
I have a widget which contains among others a qwt_thermo element for displaying a signal level. On top of that, I placed a QLabel which contains a pixmap. This pixmap is a red LED turned off. When the signal level exceeds the desired range, I replace the pixmap with the one of a flashing LED.
I update the signal levels every 20 miliseconds. As long as the signal pixmap is not switched, everything runs smoothly but as soon as the pixmap is changed, the thermo elements aren't running smoothly anymore (the LED is flashing correctly).
I load the pixmaps in the constructor of the class, so they are just swapped when necessary.
The thermo level is set in a slot and the pixmap is changed in a different slot.
Should I use QueuedConnection, maybe?
Are there any performance issues I am missing?
Here, the simplified code:
...
QPixmap* qpxRedLEDOff = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOff12x6.png"));
QPixmap* qpxRedLEDOn = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOn12x6.png"));
peakLimOn=false;
ledPeak = new QLabel();
...
void LevelWidget::setLevel(double l)
{
thermoLevel->setValue(l);
}
void LevelWidget::switchPeakLED(bool on)
{
if (on!=peakLimOn)
{
peakLimOn=on;
if (on)
{
ledPeak->setPixmap(*qpxRedLEDOn);
}
else
{
ledPeak->setPixmap(*qpxRedLEDOff);
}
}
}
Regards,
Rainer
I have a widget which contains among others a qwt_thermo element for displaying a signal level. On top of that, I placed a QLabel which contains a pixmap. This pixmap is a red LED turned off. When the signal level exceeds the desired range, I replace the pixmap with the one of a flashing LED.
I update the signal levels every 20 miliseconds. As long as the signal pixmap is not switched, everything runs smoothly but as soon as the pixmap is changed, the thermo elements aren't running smoothly anymore (the LED is flashing correctly).
I load the pixmaps in the constructor of the class, so they are just swapped when necessary.
The thermo level is set in a slot and the pixmap is changed in a different slot.
Should I use QueuedConnection, maybe?
Are there any performance issues I am missing?
Here, the simplified code:
...
QPixmap* qpxRedLEDOff = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOff12x6.png"));
QPixmap* qpxRedLEDOn = new QPixmap(QString::fromUtf8(":/resources/LED/RedLEDOn12x6.png"));
peakLimOn=false;
ledPeak = new QLabel();
...
void LevelWidget::setLevel(double l)
{
thermoLevel->setValue(l);
}
void LevelWidget::switchPeakLED(bool on)
{
if (on!=peakLimOn)
{
peakLimOn=on;
if (on)
{
ledPeak->setPixmap(*qpxRedLEDOn);
}
else
{
ledPeak->setPixmap(*qpxRedLEDOff);
}
}
}
Regards,
Rainer