QWidget ::activateWindow() - behavior under windows

The documentation for QWidget::activateWindow() [doc.qt.nokia.com] states:

“On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.”

However, there is a workaround for this problem. Namely changing the following registry keys will result in the desired behaviour

  1. HKEY_CURRENT_USER\Control Panel\Desktop
  2. ForegroundFlashCount = REG_DWORD 0x00000003
  3. ForegroundLockTimeout = REG_DWORD 0x00000000

These registry entries can be set using QSettings [doc.qt.nokia.com] .

e.g:

  1. QSettings settings("HKEY_CURRENT_USER\\Control Panel\\Desktop ", QSettings::NativeFormat, this);
  2. settings.setValue("ForegroundFlashCount", 3);
  3. settings.setValue("ForegroundLockTimeout", 0 );

Note that changing these registry settings using QSettings will change them globally on your computer, not only for your application.

A restart of the computer, or a user log-off and relog-on is required after changing the registry keys to make this work.

It has been suggested to add this workaround to the Qt Documentation, see:
http://bugreports.qt.nokia.com/browse/QTBUG-14062

No comments

Write a comment

Sorry, you must be logged in to post a comment.