Pergunta

I have occured a problem: I'm writing a widget, which displays current date's day number. It's like a button, but it's not derived from QPushButton class. Just from QWidget. So I reimplemented enterEvent(), leaveEvent(), mousePressEvent(), mouseReleaseEvent(). I call update() inside these methods and widget has realistic button behavior (paintEvent() is reimplemented too). But when I change system date and hover that widget with other window, my widget doesn't calls paintEvent() and displays old date. Only when I place mouse over it, widget repaints it's contents. I guess there is an option, which paints old contents on hover event to avoid unnecessary paint events. But I need to disable it. Tried to set many attributes (Qt::WidgetAttribute enum). But it doesn't helps.

Please, help me (and sorry for my bad english).

Foi útil?

Solução

I think you should find a way to detect that the system time has changed and call update() when that happens. Any other method (like detecting the "hovering" of a window or waiting for a mouse event) will cause the update to occur too late.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top