QML Error: When matching arguments for CustomTabButton_QMLTYPE_10::buttonClicked(): Too many arguments, ignoring 1. But there are no arguments?
-
I am trying to create a QML custom button for a tab. I have made a new signal called buttonSignal that is connected to the clicked signal in a MouseArea. I have done this because for some reason the slots that are written as on<Signal> don't work in dynamically created qml. I call the onButtonClicked when a button is clicked but i get an error:
When matching arguments for CustomTabButton_QMLTYPE_10::buttonClicked():
Too many arguments, ignoring 1
Which is weird because i don't have any arguments.
where i create a CustomTabButtonCustomTabButton{ id: firstButton onButtonClicked: { console.log("button clicked"); } }CustomTabButton.qml
import QtQuick 6.2 Rectangle{ id: buttonRect width: 100 height: 20 radius: 2 color: "#B2BEB5" signal buttonClicked; Component.onCompleted:{ mouseArea.clicked.connect(buttonClicked); } Text{ id: buttonText anchors.centerIn: parent text: qsTr("TESTING") } MouseArea{ id: mouseArea anchors.fill: parent cursorShape: Qt.PointingHandCursor hoverEnabled: true } } -
You say: "I don't have any arguments." I believe I know what you mean when you say that. You are saying that your custom signal
signal buttonClickedtakes no arguments.But I think that misses the point.
The reason there are "too many arguments" is that the original signal does have one argument:
clicked(MouseEvent mouse)(refer to docs: https://doc.qt.io/qt-6/qml-qtquick-mousearea.html#clicked-signal)
What the error is trying to tell you (I believe) is that when you try to connect (i.e. pass along) the MouseArea's signal to your own, the MouseArea's signal carries too many arguments (too many to match the signature of what you want to connect it to).
-
D Dizarc has marked this topic as solved on