2
votes

I'm using Qt 4.4 and my application opens a modeless QDialog that refreshes its contents every 5 seconds using a timer. That is working just fine, but I would like to have the refresh not happen when the dialog is not visible.

I've tried using isVisible()/isHidden() and showEvent(QTimerEvent *event)/hideEvent(QTimerEvent *event) but those seem to only indicate when it is first popped up or minimized and reveal no information about when it is behind the main window of the application.

isActiveWindow() seems to indicate a slightly related idea, but if possible, I would like to have the window refresh if it's open next to the main window and still visible but not actively being used by the user.

1

1 Answers

2
votes

I don't believe there is any direct support for this but I think you can probably make this work by checking the coordinates and the focus widget. If the current focus widget is on the main form and there is more than some percentage of overlap between the dialog and the main form, as determined based on their position and size, then don't refresh.