I am working on a project where I have to simulate a Unix environment in my Windows application. That is, I want to have the active component automatically change to be the window or control under the cursor. Specifically, I need to have the space bar press the button under the cursor (for all buttons on all windows in my application). My first question is: Is there any way to turn on a "focus when mouse over" policy in QT (either globally or on a per control basis)?

Since I could not find a "focus when mouse over" ability in QT, as a test case, I tried to create MyHoverButton derived from QPushButton. In order to use MyHoverButton I changed QPushButton to MyHoverButton in one of my Dialog.ui files. However, when QT tried to process this file it placed "#include <MyHoverButton.h>" in the ui_dialog.h file. Since, MyHoverButton.h is in my project's directory and not the System or QT directory, the code will not compile. I could change the line in the ui_dialog.h to #include "MyHoverButton.h" however, the next time QT compiles the .ui file, it will place the "#include <MyHoverButton.h>" line back in the file. My second question is: How can I change the class defined in the QT designer from the standard QT control (like QPushButton) to a custom control derived from the standard control in a way that does not break the QT designer?