Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to position a component at the top of all my QML views

Tags:

javascript

qt

qml

I have a QML Menu component that I would like to place at the top of each and everyone of my views and sort of sync up so it goes the look and feel of the typical webpage menu. How do I go about doing this please

import QtQuick 1.0 

Row {
    width: 500
    height: 50
    anchors.centerIn: parent
    spacing: parent.width/6

    Button {
         id: loadButton
         text: qsTr("Menu")
    }
    Button { 
         id: saveButton
         text: qsTr("Profile")
    }
    Button {
         id: exitButton
         text: qsTr("View Products")
    }

}
like image 565
Kobojunkie Avatar asked Feb 04 '12 11:02

Kobojunkie


1 Answers

Read about "z" property QDeclarativeItem or QML Item. The answer is to give your menu component instance the highest z value.

MyMenu
{
   z: 100

   ...
}

Rectangle
{
   z: 1

   ...
}

The qml renderer decides upon this values which items to draw first; and in case of something overlaying your menu it will end below it. By the way, the default z value is 0, so all are same and it is more or less undefined in which order it is rendered.

Good Luck!

like image 62
muenalan Avatar answered Nov 14 '22 22:11

muenalan