Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm developing an Ubuntu SDK meant to be used on both the desktop and touch interfaces. Obviously the menu that slides up from the bottom of the window is not a great interface for the desktop.

I'd like to be able to redundantly add the items there to a normal application menu (appmenu) to be used on the desktop. How can this be done in a QML application? I've found no documentation, only a mention of the possibility in Qt here:

http://blog.qt.digia.com/blog/2011/08/26/toplevel-windows-and-menus-with-qt-quick/

Edit: I found mention of the library needed in the question Are Qt Quick Controls available on Ubuntu 13.10? . If I can turn that into a solution, I'll post the answer.

Edit: After adding the ubuntu-sdk-team/ppa and canonical-qt5-edgers/qt5-proper PPAs and upgrading, I still don't have QtQuick.Controls. And yes, I'm running Trusty.

Update: it seems that the packages are in place in Trusty now, and the import of QtQuick.Controls is working correctly. However, when I add a menu to my app, it has no effect. No menu appears. Any advice?

Update: I tried again since the release of 14.04, but nothing changed. I tried Ubuntu.HUD (code in this Sudoku app), an actions attribute (later in the Sudoku app, even trying to use ApplicationWindow (which doesn't exist), but the menu simply does not appear on the window, and dragging up the menu from the bottom doesn't show the touch HUD. And since it always gives the "Must provide APP_ID environmental variable or HUD will not work" error when running, I ran it from the terminal with an APP_ID set. Still nothing.

Window {
    visible: true
    width: units.gu(40)
    height: units.gu(75)
    title: "My App"

    MenuBar {
        Menu {
            title: "File"
            MenuItem {
                 text: "Quit"
            }
        }
    }

    MainView {

        id: root
        // objectName for functional testing purposes (autopilot-qt5)
        objectName: "mainView"
        // ...
share|improve this question
    
QtQuickControls are only available with Qt >= 5.1. To follow the progress of Qt 5.2 in Trusty, please look at the requested FFe –  Sylvain Pineau Mar 8 at 15:57
    
The examples for the Quick Controls menus is as such: menuBar: MenuBar { } I believe menuBar is a member of ApplicationWindow, so maybe you need to reverse engineer this to get MenuBar to work in MainView? Otherwise I think you are defining a MenuBar but it's not actually being placed in the window (I could be wrong). Also, now that Trusty is officially released things may have changed, you should try again and post your results. I'm quite curious if you get this working, if you find a solution please do post! –  KoRnKloWn Apr 25 at 18:44
    
@KoRnKloWn still isn't working :-( –  Jonah Apr 25 at 23:00
    
Have you tried using ApplicationWindow instead of Window? You would have to set the menu bar to the property menuBar, (as I showed above), then the MainView would be below the MenuBar. –  KoRnKloWn Apr 29 at 21:57
    
ApplicationWindow does exist, not sure which import it's in but this is what I imported to get it: import QtQuick.Controls 1.1 & import QtQuick.Dialogs 1.1 & import QtQuick 2.2. –  KoRnKloWn May 17 at 19:34

2 Answers 2

The transition from Qt 5.0 to 5.2 in the Ubuntu 14.04 LTS cycle was (and remains, at the time of writing) a long process that was much more drawn-out than many people wanted.

QtQuickControls are available with Qt >= 5.1, so the final 14.04 release should let you design applications with appmenu.

share|improve this answer
    
Did you try with Trusty Beta 2? –  Sylvain Pineau Apr 14 at 15:36
    
Yup, I've tried it since 14.04 has been released, but it still doesn't do anything. –  Jonah Apr 25 at 22:58

I also experienced this problem with Ubuntu 14.04. There was no menu appearing in the Qt Quick Application that I was creating, even the unmodified template "Hello World" application would not show a menu (either in the application window, or in the Ubuntu menu at the top of the screen).

The solution for me was to install a personal copy of the latest Qt package, using the binary installer for Linux (http://qt-project.org/downloads). It included Qt 5.2.1, and Creator 3.1.0.

I installed it into $HOME/Qt as recommended.

When I run the latest Qt Creator and bundle, I now see the application menu appearing as a traditional Windows Style menu in the application window.

share|improve this answer
    
I'll have to give that a whirl, but it wouldn't be an ultimate solution if the user has to manually install Qt :( –  Jonah May 5 at 19:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.