B
B
beduin012015-10-04 10:18:57
QML
beduin01, 2015-10-04 10:18:57

How to pass values ​​in QML?

I am learning QML. I'm trying to figure out how to pass values. I want to pass the value of the last opened file to recentFilesMenu.
I'm trying to do this:

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.0

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

    menuBar : MenuBar
    {
        Menu
        {
            id: recentFilesMenu
            Instantiator
                {
                    model: recentFilesMenu
                    MenuItem
                    {
                        text: model.fileName // Вот сюда передать надо
                    }
                    onObjectAdded: recentFilesMenu.insertItem(index, object)
                }

            title: "File"
            MenuItem
            {
                text: "Open"
                onTriggered: fileDialog.visible = true

            }


            MenuItem
            {
                text: "Exit"
            }
        }


    }

    FileDialog
        {
            id: fileDialog
            title: "Oooopen"
            onAccepted:
            {
             // вот отсюда
            recentFilesMenu.objectName = fileDialog.fileUrls
            }
        }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacob E, 2015-10-04
@beduin01

I propose to start with something simpler, for example, from these articles on Habré.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question