+1  A: 

If you don't want the default windows mobile behavior you will need to call the function SHDoneButton.

It takes three possible arguments:

  • SHDB_HIDE - which is the default and WM most likely displays the 'X' button and will minimize your app when it's pressed. Also note on some devices the 'X' button will send a WM_QUIT to your application.

  • SHDB_SHOW - will show a 'ok' button and will send a IDOK WM_COMMAND to your window when pressed.

  • SHDB_SHOWCANCEL - will show a 'x' button and will send a IDCANCEL WM_COMMAND to your window when pressed.

Shane Powell
+4  A: 

The "Smart Minimize" button is handled by a style bit typically set when the Windows is created - specifically WS_NONAVDONEBUTTON. For a CF application, this is controlled by setting the MinimizeButton property to false. In C/C++, it is done by adding the bit when calling CreateWindow or setting the bit afterward (directly or, as Shane suggests, via SHDoneButton).

Qt is obviously creating a Window, so it's in that process that you need to change the style bit. I'm not a Qt developer, so exactly how it's done in that framework I don't know.

ctacke
+1  A: 

Thanks for your indispensable answers. They all contributed to my solution. When I tried to change X button to OK button, I found out that there is a Windows CE specific flag to make OK button visible.

 #ifdef Q_OS_WINCE
       setWindowFlags(windowFlags()|Qt::WindowOkButtonHint);
 #endif

after setting that Button, I have overrided event(QEvent*) function to catch the event fired from OK in order to close the application.

bool MainWindow::event(QEvent *mEvent)
{   

    if (mEvent->type()==QEvent::OkRequest)
    {
         qApp->closeAllWindows();
         return true; 
    }

    return QMainWindow::event(mEvent);

}

and now it works like a charm =)

Comptrol