@federico.massimi please mention my username next time you answer, so I can see that you have answered :D
Okay, I need to be more spesific. I mean, for example you have a function doThat() in file function1.cpp and a button inside myqmlfile.qml. You can create a registery for the file function1.cpp as a QML registery in main.cpp
See QML C++ Integration Page for more.
And import your cpp file into myqmlfile.qml
And create the function for the button press trigger inside myqmlfile.qml
Function1{ id: function1 } Rectangle{ id: buttonbg width: 120 height: 70 radius: 8 color:"black" anchors.centerIn: parent Text{ anchors.centerIn: parent text:qsTr("Do Function") font.pixelSize: 18 color: "white" } MouseArea{ anchors.fill: parent onClicked: { function1.doThat() //will execute your function on clicked } onPressed: { buttonbg.color = "#1c1c1c" //to change bgcolor on pressed } onReleased: { buttonbg.color = "black" //to change bgcolor on released } } }