Triggering ComboBox Accepted signal using a button outside of ComboBox
-
Hi,
I have a ComboBox on a form. I also have a button on the form which the user need to press to process the data on the form.ComboBox {
width: 200
model: [ "Banana", "Apple", "Coconut" ]
}Right now I have to click on the ComboBox to accept the content and trigger the Accepted() signal.
Is it possible to accept the ComboBox content and trigger the Accepted() signal using a StyledButton which is independent from the ComboBox?
The goal is to read all the textfield and ComboBox content by clicking only once at the StyledButton.
Thank you. -
Signals are very similar to functions, you may simply call this signal manually like
yourComboBoxId.accepted()
atonClicked
button's slot. -
Signals are very similar to functions, you may simply call this signal manually like
yourComboBoxId.accepted()
atonClicked
button's slot.Hi @intruderexcluder ,
I triedWhatCombo.accepted()
accepted() was not offered as an option after hitting .
It did not give any specific error messages just doesn't work.
Thank you. -
I was talking about like this:
... MyCustomComboBox { id: mycombo ... } ... MyCustomButton { ... onClicked: { ... mycombo.accepted(); } }
-
I was talking about like this:
... MyCustomComboBox { id: mycombo ... } ... MyCustomButton { ... onClicked: { ... mycombo.accepted(); } }
@intruderexcluder
I have the following:WhatCombo { id: whatCombo anchors.left: comboInstruct.left anchors.top: comboInstruct.bottom anchors.topMargin: 10 } onClicked: { console.log("submit clicked.") whatCombo.accepted() }
I think it should work, but it doesn't.
-
Just wrote a minumum example and it works fine:
Window { id: root visible: true width: 640 height: 480 title: qsTr("Hello World") ComboBox { id: cb model: ["asd", "qwe", "zxc"] } Button { anchors.centerIn: parent text: "Test" onClicked: cb.accepted() } Connections { target: cb onAccepted: console.log("COMBO ACCEPTED"); } }