Skip to content

Instantly share code, notes, and snippets.

@Avanznow
Last active January 3, 2016 01:39
Show Gist options
  • Save Avanznow/8390923 to your computer and use it in GitHub Desktop.
Save Avanznow/8390923 to your computer and use it in GitHub Desktop.
Android iOS cross-mobile Qt/QML signal button to C++
/*
Copyright (C) 2014 Adrian Silva <http://avanznow.wordpress.com/contact>
This program is free software; you can redistribute it and/or
modify it under the terms of the New BSD Berkeley Software Distribution License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the BSD General Public
License for more details. - http://opensource.org/licenses/BSD-3-Clause
https://www.freebsd.org/doc/en_US.ISO8859-1/articles/bsdl-gpl/article.html
*/
import QtQuick 2.0
Rectangle {
id: page
width: 200
height: 50
x: 10
y: 10
signal qmlSignal(string msg)
property int pressCount: 0
Text {
text: "PressCount: " + page.clickedCount
color: "#ff0000"
}
Text {
text: qsTr("QML toolkit - button activated")
anchors.centerIn: parent
}
//========================================//
// Init:: container_buttonOK
Rectangle {
id: container_buttonOK
x: 146
y: 231
width: 64
height: 59
color: "#00000000"
Rectangle {
id: buttonRect
x: 0
y: 2
width: 64
height: 56
radius: 14
Text {
id: textLabel_ok
x: 24
y: 19
text: "Ok"
font.pixelSize: 12
}
border.width: 6
gradient: Gradient {
GradientStop {
position: 0
color: "#bff6fe"
}
GradientStop {
position: 1
color: "#000000"
}
}
clip: false
}
MouseArea {
hoverEnabled: false
anchors.fill: parent
onClicked: {
console.log("got-clicked")
page.clickedCount++
page.qmlSignal("Clicked :: "+page.clickedCount)
}
}
}
// End:: container_buttonOK
//========================================//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment