Results 1 to 3 of 3

Thread: Qt QML MenuBar and Menus not showing

  1. #1
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Qt QML MenuBar and Menus not showing

    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).

    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.0
    3.  
    4. ApplicationWindow {
    5. visible: true;
    6. width: 1000;
    7. height: 700;
    8. title: "App";
    9. MenuBar {
    10. Menu {
    11. title: "File"
    12. MenuItem { text: "Open..." }
    13. MenuItem { text: "Close" }
    14. }
    15.  
    16. Menu {
    17. title: "Edit"
    18. MenuItem { text: "Cut" }
    19. MenuItem { text: "Copy" }
    20. MenuItem { text: "Paste" }
    21. }
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    Can someone help?

  2. #2
    Join Date
    Jun 2009
    Location
    Krakow, Poland
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt QML MenuBar and Menus not showing

    Try like this:
    Qt Code:
    1. import QtQuick 2.1
    2. import QtQuick.Controls 1.0
    3. import QtQuick.Window 2.0
    4.  
    5. ApplicationWindow {
    6. title: qsTr("Hello World")
    7. width: 640
    8. height: 480
    9.  
    10. menuBar: MenuBar {
    11. Menu {
    12. title: qsTr("File")
    13. MenuItem {
    14. text: qsTr("Exit")
    15. onTriggered: Qt.quit();
    16. }
    17. }
    18. }
    19.  
    20. Button {
    21. text: qsTr("Hello World")
    22. anchors.horizontalCenter: parent.horizontalCenter
    23. anchors.verticalCenter: parent.verticalCenter
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qt QML MenuBar and Menus not showing

    Thank You.It worked very well.

Similar Threads

  1. Customize the menubar and menus
    By tonnot in forum Newbie
    Replies: 4
    Last Post: 16th February 2011, 14:09
  2. Context Menus
    By rodlbr in forum Qt Programming
    Replies: 4
    Last Post: 7th September 2009, 16:30
  3. Accessible menus
    By NickPoole in forum Qt Programming
    Replies: 3
    Last Post: 17th August 2009, 09:30
  4. Showing and hiding menubar
    By borges in forum Newbie
    Replies: 1
    Last Post: 23rd September 2007, 10:56
  5. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.