Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Custom menu item does not work.



  • My menu item stopped opening after migrating to QT6.2:

                                    Menu
                                    {
                                        title: qsTr("Scene Test")
    
                                        TestMenuItem {
                                            text: qsTr("Off")
                                            testId: 0
                                        }
    
                                        TestMenuItem {
                                            text: qsTr("Lighted Cube")
                                            testId: 1
                                        }
    
                                        TestMenuItem {
                                            text: qsTr("Colored Cube")
                                            testId: 2
                                        }
                                    }
    

    My custom menu item in TestMenuItem.qml:

    import QtQuick 2.7
    import QtQuick.Controls 2.3
    import QtQuick.Layouts 1.3
    import QtQuick.Window 2.2
    
    MenuItem
    {
        property int testId
    
        checkable: true
    
        checked: scene.testMode === testId
    
        onTriggered: scene.testMode = testId
    }
    

    Clicking on Scene Test item does not have an effect.

    It worked previously in QT 5.15.2.

    And it works in QT6.2 without my custom menu item:

                                    Menu
                                    {
                                        title: qsTr("Scene Test")
    
                                        MenuItem
                                        {
                                            checkable: true
                                            checked: scene.testMode === 0
                                            onTriggered: scene.testMode = 0
                                            text: qsTr("Off")
                                        }
    
                                        MenuItem
                                        {
                                            checkable: true
                                            checked: scene.testMode === 1
                                            onTriggered: scene.testMode = 1
                                            text: qsTr("Lighted Cube")
                                        }
    
                                        MenuItem
                                        {
                                            checkable: true
                                            checked: scene.testMode === 2
                                            onTriggered: scene.testMode = 2
                                            text: qsTr("Colored Cube")
                                        }
                                    }
    

    What changed in QT6.2?


Log in to reply