PDA

View Full Version : Qt QML MenuBar and Menus not showing



adutzu89
7th October 2013, 11:30
I'm new to Qt and Qt/QML and I am trying to setup a menubar but it doesn't show it at all.

I've copied pasted the code and still nothing(from Qt doc).


import QtQuick 2.0
import QtQuick.Controls 1.0

ApplicationWindow {
visible: true;
width: 1000;
height: 700;
title: "App";
MenuBar {
Menu {
title: "File"
MenuItem { text: "Open..." }
MenuItem { text: "Close" }
}

Menu {
title: "Edit"
MenuItem { text: "Cut" }
MenuItem { text: "Copy" }
MenuItem { text: "Paste" }
}
}
}

Can someone help?

porterneon
7th October 2013, 11:40
Try like this:


import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0

ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480

menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}

Button {
text: qsTr("Hello World")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}

adutzu89
7th October 2013, 11:51
Thank You.It worked very well.