September 24, 2011

qgil qgil
Ant Farmer
86 posts

[Solved] Menu component “falling” from center of the page instead of emerging from bottom

 

Hi, Menu components in MeeGo Harmattan apps pre-installed in the N9 emerge from the bottom of the display. However, in my app appears at the center of the display and then “falls” until hitting the ToolBar. I haven’t been able to find anything special in my code instructing that, neither I have found in the docs any reference to different animations for Menu components to show up.

For what is worth this is the structure of the code:

  1.     ToolBar {
  2.  
  3.         tools: ToolBarLayout {
  4.  
  5.             ToolIcon {
  6.                 id: backIcon
  7.                 iconId: "toolbar-back";
  8.                 onClicked: {
  9.                     exitMenu.open()
  10.                 }
  11.  
  12.                 Menu {
  13.                     id: exitMenu
  14.  
  15.                     MenuLayout {
  16.                         MenuItem { ... }
  17.                         MenuItem { ... }
  18.                         MenuItem { ... }
  19.                         MenuItem { ... }
  20.                     }
  21.                 }
  22.             }

The qml file can be found at http://gitorious.org/miniature/miniature/blobs/master/src/frontend/OnlineBoard.qml

6 replies

September 25, 2011

Alicemirror Alicemirror
Lab Rat
825 posts

Hi, I saw that toolbars and buttons will be anchored somewhere in the screen anyway. Did you tried?

It is not obvious that the toolbar that we always see to the tbottom will be set there by Qt. In my applications all toolbars (from which the menu depends) are anchored to the bottom of the screen.

 Signature 

Enrico Miglino (aka Alicemirror)
Tech Consulting
Islas Baleares, Ibiza (Spain)
http://www.contesti.eu

September 26, 2011

qgil qgil
Ant Farmer
86 posts

Yes, the ToolBar contains already

  1. anchors.bottom: parent.bottom

otherwise the Page is not usable at all (? but this is irrelevant here).

I found your idea interesting and I added “anchors.bottom: parent.bottom” to the rest of components involved, but the problem stays. Somehow the Menu wants to appear at the middle of the screen instead of emerging from the bottom…

September 26, 2011

gri gri
Lab Rat
39 posts

Please also try creating the Menu outside of the ToolBar so that the Page is its parent element. Then no anchors should be needed.

September 26, 2011

qgil qgil
Ant Farmer
86 posts
gri wrote:
Please also try creating the Menu outside of the ToolBar so that the Page is its parent element. Then no anchors should be needed.

THAT WAS IT! Thank you very much.

Putting the Menu outside the toolbar as a child of Page makes it behave just like it should, without needing to anchor it anywhere.

So simple. And so not-evident. It doesn’t make much sense to me but then again I’m not a compiler. ;)

Thanks again!

September 26, 2011

gri gri
Lab Rat
39 posts

For the records: Creating a ToolBar on your own is not needed in most cases.

Following code should run fine:

  1. Page {
  2.   // The actual content
  3.   Rectangle {
  4.     anchors.fill: parent
  5.     color: "red"
  6.   }
  7.  
  8.   tools: ToolBarLayout {
  9.     Item {}
  10.     ToolIcon {
  11.       iconId: "toolbar-view-menu"
  12.       onClicked: menu.open()
  13.     }
  14.   }
  15.  
  16.   Menu {
  17.     id: menu
  18.  
  19.     MenuLayout {
  20.       MenuItem {
  21.         text: "hello"
  22.       }
  23.     }
  24.   }
  25. }

September 26, 2011

qgil qgil
Ant Farmer
86 posts

Oh, I see. Another thing I’ve learned.

I still don’t think I have got everything clear out of the loop of docs PageStackWindow – PageStack – Page – ToolBar – ToolBarLayout – tools… The principle and outcome is simple, yet at this point the docs themselves are more complex than needed. Looking forward to see a simplifications as soon as the com.nokia.meego stuff gets assimilated in Qt Quick components upstream.

Anyway, not an excuse for me. I’m looking again at the examples provided at http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-menu.html and they keep tool and menu separate.

 
  ‹‹ [Solved] "Widgets must be created in the GUI thread" error      [SOLVED] Model items in javascript. ››

You must log in to post a reply. Not a member yet? Register here!