[Android-development] Access to Application Menu and Preferences without HW-Button

Eskil Abrahamsen Blomfeldt eskil.abrahamsen-blomfeldt at digia.com
Tue Sep 17 09:26:17 CEST 2013


On 09/16/2013 05:29 PM, Robert Iakobashvili wrote:
> Hello,
> Some Android devices do not have HW-button Menu,
> i.e. Nexus-7.
>
> What is the way to get access to the application menu
> (menu of the main window) in such cases?
>
> On devices with HW-button "Menu", pressing the button
> activates the menu.
>
> It is particularly important to access application Preferences:
> the QAction item acting as QAction::PreferencesRole menu-role.
>
> At least true for Nexus-6 Android-4.3. every active application
> sets to Android bar symbol with 3 vertical dots -
> application Preferences.
>
> Am I missing some standard way or Qt-Android specific way
> to get to the application menu and/or to application Preferences
> menu action without HW-button?
> Thank you in advance.
>

Hi,

If you mean the overflow button (three vertical squares) in the system 
navigation bar, then this is mainly a compatibility feature. If you see 
it in apps, it means they are targeted against older Android versions. 
You can get the overflow button in your app by setting both the minimum 
and the targeted Android version to 10 or lower in the manifest. If 
visible, the button should have the same effect as hardware menu buttons 
in Qt, and can be accessed using the menu APIs in QtWidgets or Qt Quick 
Controls. By default, Qt applications will set minimum version to 9 and 
targeted version to 14 so that this overflow button is not visible by 
default.

Newer apps on Android usually have a customized action bar instead. 
There is no direct support for this mechanism in Qt at the moment, but 
the same functionality should be possible to implement in e.g. QML and 
Qt Quick Controls. The overflow button in action bars is intended to 
represent the actions which could not fit in the bar, and the contents 
there will thus depend on screen size and orientation. I think the 
action bar should fit well with Qt's menu and action concepts, and we 
have the following task to support it:

     https://bugreports.qt-project.org/browse/QTBUG-32002

Here's some more information about the action bar:

     http://developer.android.com/guide/topics/ui/actionbar.html

And here's a blog about the compatibility feature which uses an overflow 
button to replace the physical menu button:

http://android-developers.blogspot.no/2012/01/say-goodbye-to-menu-button.html

Hope this helped :)

-- Eskil



More information about the Android-development mailing list