PDA

View Full Version : enterEvent / leaveEvent on Widget really slow on MacOSX



RThaden
10th February 2012, 15:37
Hi all,

I ported an application from Windows to MacOSX (10.6) and have some really undesirable behaviour.

There are about 10 widgets next to eachother and to highlight the current one, I use enterEvent and leaveEvent to change the color of the widget a bit.
The code is

void Widget::enterEvent(QEvent* event)
{
setAutoFillBackground(true);
QPalette pal=palette();
QColor bgnd = pal.color(QPalette::Window);
pal.setColor(QPalette::Window, bgnd.darker(125));
setPalette(pal);
}

void Widget::leaveEvent(QEvent* event)
{
setAutoFillBackground(false);
QPalette pal=QApplication::palette();
setPalette(pal);
}


On Windows and Linux, this works nice and smoothly. The color changes immediately follow the cursor.
On MacOSX, however, it takes about 500ms for the color to change after the cursor has entered the widget.
This means, that if the user moves with the cursor from the most left to the most right widget (10 in total), the color changes have about 5 seconds delay in total.

Any idea what might cause this?

Best regards,

Rainer

Spitfire
14th February 2012, 10:54
Try calling repaint() after changing the palette.
That will trigger immidiete repaint and should help for the lag.