Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MenuSeparator show blank line but not underline
Qt 6.11 is out! See what's new in the release blog

QML MenuSeparator show blank line but not underline

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JoyBin
    wrote on last edited by
    #1

    win10+Qt5.10.0+QML

    When using SystemTrayIcon in my qml project, I want to show a series of menus, so what I need is a underline which can separate difference menu clear.

    So a
    MenuSeparator{} use in my code, but unexpected thing happend, it is a blank white area, not a underline.

    I has to look for the Qt helper file install with my QtCreator, the picture shows it seems that MenuSeparator{} works well as a underline from the "MenuSeparator QML Type" title.

    Here is all my code in the 'SystemTray.qml' file:

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.4
    import Qt.labs.platform 1.0
    import QtQml 2.2
    
    SystemTrayIcon {
        id: tray_main
        visible: true
        tooltip: service.tooltip
    
        property ConfigureView cfg_dlg: ConfigureView{}
        menu: Menu {
            id: tray_menu
            MenuItem {
                text: qsTr("connect")
                checkable: true
                checked: configure.enable
                onCheckedChanged: {
                    configure.enable = checked
                    tray_main.iconSource = checked ? "qrc:/images/logo.ico" : "qrc:/images/logo_1.ico";
                }
            }
            Menu {
                id: server_list
                title: /*qsTr(*/"server list"/*)*/
                **MenuSeparator {}**
                MenuItem {
                    text: qsTr("configure server...")
                    onTriggered: {
                        cfg_dlg.show()
                    }
                }
            }
            **MenuSeparator {}**
            MenuItem {
                text: qsTr("start-up")
                checkable: true
                checked: service.startUp()
                onCheckedChanged: {
                    service.setStartUp(checked)
                }
            }
            MenuItem {
                text: qsTr("quit")
                onTriggered: {
                    service.stop()
                    Qt.quit()
                }
            }
    
            /////////////////////////////////////////////////////////////////
            Instantiator {
                model: listModel//configure.serverLists
                onObjectAdded: server_list.insertItem(index, object)
                onObjectRemoved: server_list.removeItem(object)
                delegate: MenuItem {
                    checkable: true
                    checked: configure.index == index
                    text: remarks + "(" + ip + ":" + port + ")"//modelData
                    onCheckedChanged: {
                        if (checked != (configure.index == index)) {//to avoid loop first time
                            configure.index = index
                        }
                    }
                }
            }
        }
    }
    

    Is there something wrong ? could anybody help me ! Thanks for your help!

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      The bug was noticed and fixed recently: QTBUG-66642. Sorry for the inconvenience, the implementation of native platform menus for Windows is brand new in Qt 5.10. :)

      J 1 Reply Last reply
      0
      • jpnurmiJ jpnurmi

        The bug was noticed and fixed recently: QTBUG-66642. Sorry for the inconvenience, the implementation of native platform menus for Windows is brand new in Qt 5.10. :)

        J Offline
        J Offline
        JoyBin
        wrote on last edited by
        #3

        @jpnurmi Thanks for your help !

        And there is another question in the following code:

                Menu {
                    id: server_list
                    title: /*qsTr(*/"server list"/*)*/
                    MenuSeparator {}
                    MenuItem {
                        text: qsTr("configure server...")
                        onTriggered: {
                            cfg_dlg.show()
                        }
                    }
                }
        
        title: /*qsTr(*/"server list"/*)*/  //show "server list"
        title: qsTr("server list")  //just an blank menu with no anyother word
        

        win10+Qt5.10.0+QML

        1 Reply Last reply
        0
        • jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          Ouch. :( The good news is that that one has also been fixed: QTBUG-66876

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved