PDA

View Full Version : Performance problems with small pixmap



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

jacek
8th July 2008, 23:48
Are you sure that qpxRedLEDOff and qpxRedLEDOn from lines 2 & 3 are the same variables as the ones from lines 21 & 25? Do you use threads?

RThaden
9th July 2008, 01:13
Hi jacek,

thanks for your quick reply.

Yes, pretty sure. The lines 2 & 3 are in the constructor of the class and the variables are declared in the header. I just wrote the declaration here for clarity.
I use threads, but the updates of the qwt_thermo and the pixmap are done subsequently via direct call of the slots. No signals are used here.
And the pixmap is only updated, if the value changes.
Also, the pixmap is only 12x6 pixel big. There shouldn't be a performance issue.

Could it be something with allocating the pixmaps on the heap / on the stack? Guess, that's not very probable.

Regards,

Rainer

RThaden
9th July 2008, 14:06
Hi again,

I am pretty clueless about that.
I tried to add a static variable inside the function which sets the pixmap. That works, but still I have no fluid animation.
Then, I thought that maybe the setPixmap triggers some "re-layout" of the whole thing, so I took the pixmap out of the layout and used fix coordinates.
No changes.

Could it be an issue with Qwt? Maybe I should post at the Qwt list.

Regards,

Rainer

RThaden
9th July 2008, 15:14
Found it!



ledPeak->setMinimumHeight(qpxRedLEDOff->height());
ledPeak->setMinimumWidth(qpxRedLEDOff->width());
ledPeak->setMaximumHeight(qpxRedLEDOff->height());
ledPeak->setMaximumWidth(qpxRedLEDOff->width());


When I give the pixmaps fixed mins and maxs (in this case, these are the same values), the animation is fluid.
If I leave out the fixed max or min setting, the animation is not fluid anymore.

Regards,

Rainer