S
S
sitev_ru2017-03-17 11:17:33
Qt
sitev_ru, 2017-03-17 11:17:33

How to set the correct OnClicked for a button?

I set the button in the QML file, everything is fine

Button {
        signal qmlSignal()
        onClicked: {
            qmlSignal()
        }
    }

and if I set it in the UI.QML file, then a message appears: "Javascript blocks are not supported in the Qt Quick form."
How to set the correct OnClicked for a button?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TriKrista, 2017-03-17
@sitev_ru

Alternatively, in the UI we write:

// MainForm.ui.qml
property alias btnName: btnName

and where we use the form, we write:
MainForm {
        id: mainForm

        btnName.onClicked: {
        }
}

J
Jacob E, 2017-03-17
@Zifix

a) Don't bother with ui files, at least at first
b) Create a new project with a ui form, there is a good example of how to work with it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question