I have these 2 buttons and I want to click on both to open the onClick action of the second button. How can I do that to get my desired result? Maybe to use signals?
Button {
id: btnLevel1
x: 1016
y: 492
width: 554
height: 67
onClicked: classA.newGameWindow()
text: "May God\nHave Mercy"
background: Rectangle {
color: "transparent"
}
font.family: "Inria Serif"
font.pixelSize: 20
}
Text {
id: very_hard_level
color: "white"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop
wrapMode: Text.Wrap
font.weight: Font.Normal
}
Button {
id: btn2
x: 58
y: 246
width: 188
height: 34
onClicked: classA.newGameWindow()
text: qsTr("New Game")
background: Rectangle {
color: "transparent"
}
font.family: "Inria Serif"
font.pixelSize: 26
Text {
id: new_Game
color: "white"
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignTop
wrapMode: Text.Wrap
font.weight: Font.Normal
}
}
I tried to use MouseArea but didn't work and I don't know what to do
I still don't fully understand your use case hence the solution could be wrong.
I've used a button group to keep track of the buttons in use and also to unify the
onClickedsignal call. One pitfall here could be to add aAbstractButtonthat doesn't have the custom propertyactivatedwhich can be checked for.When a button is pressed the
activatedproperty of that button is set totrue, if not all buttons of the group areactivatedthe function exits, if all buttons areactivatedthe background of the rootWindowis set to yellow, which would be your entry point to call a function as far as I understood your example. Also the custom buttonMyButtonincludes an indicatorRectangleto show theactivatedstate of that button.That said depending on your use case there could potentially be better solutions to your problem.