DRY with Actions in QtControls 2



  • Hello,

    I m fairly new and experimenting with the flavors of QT/QML, so please bare with me if I m not being clear.

    When using Qt Quick Controls 1._ I was able to figure out that using Action{} in QML, i can eliminate repeated code when trying to use Menu's (file, edit) and corresponding Toolbuttons. So The same Action was able to identify the icon for the toolbar, and the text with the & shortcut for the MenuItem.

    The action looked something like
    Action
    {
    id: newFileActionId
    text: qsTr("&file")
    iconSource: "url"
    onTriggered: Something.Done()

    }
    I am trying to do something similar using Qt QuickControls 2.3. The difference is that when i try to use the icon, the Text still shows up. I tried ditching icons all together, using a specialized font to create my icons. This works, but the Action Text seems to override the content inside my MenuItem or ToolButton. This is even true when i dont add the text property to Action. I looked at the QT TextEditor Example for QtControls 2, and even there, they just repeat the same commands. If someone knows how to get the DRY style like in QtQuickControls 1._ , I would really appreciate the instruction.

    Thank you.

    Ps: i have to use the msvc 2013 compiler and so am using Qt 5.10 for now.