Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Native Symbian Note Dialogs in Qt Apps
Especially if using a QWidget based UI on the Symbian platform, many standard dialogs as provided by Qt currently don't look as good as the native variants. Some other dialogs are not available from within Qt.
The recommended alternative is using Qt Quick Components. If this is not suitable in your situation, an alternative is re-implementing the dialog manually. However, especially when it's required to stick to the device UI look & feel, the best remaining alternative is to integrate a native Symbian dialog into a Qt app.
Showing a standard native Symbian note dialog is easy, as those can be setup and instantiated only from the source code - this article explains how to do that through the example of a confirmation note dialog.
If a definition in a Symbian resource file is required or recommended (e.g., for progress dialogs), several steps are necessary to make it work - see this article.
Download the attached example, which demonstrates showing a Symbian confirmation note dialog from a Qt Hello World app. The key steps are explained here. The example can be self-signed. Use at least Qt SDK 1.1 (final) and ensure you enable the "Native API Support" in the Symbian Toolchains section of the Qt SDK Maintenance tool.
Qt .pro file
In the project file, native Symbian libraries need to be added:
LIBS += -lavkon \
Showing the note dialog on the screen
The text for this example is defined as a QString to easily integrate with the rest of your application. The next line converts this to a Symbian descriptor, which can be passed to a native Symbian method. The last two lines of the method create a confirmation note (CAknConfirmationNote) and execute it, passing the text.
// Define the text you want to show in the note dialog
QString noteText = "Success";
// Convert the Qt String to a Symbian Descriptor
TPtrC16 noteTextPtr(reinterpret_cast<const TUint16*>(noteText.utf16()));
// Create a new confirmation note (pre-defined in S60 framework)
CAknConfirmationNote* noteConfirm = new (ELeave) CAknConfirmationNote;
// Displays and deletes the dialog – you don’t have to delete it yourself!
// As this method can potentially leave (the method has an L at the end of its name),
// convert any resulting error into an exception
When you launch the app, it will load the UI. Press on the push button in the mittle of the screen to show the confirmation dialog. By default, it will dismiss itself after a short amount of time.
Note that this example only works when executed on a Symbian device - you can not use the simulator to test it, as the simulator isn't based on Symbian OS. The code snippet above only uses the code when compiling for the Symbian platform through the ifdef statements.
Import the test app to your Qt Creator as part of the Qt SDK.