Created
December 28, 2010 19:36
-
-
Save elpuri/757597 to your computer and use it in GitHub Desktop.
A button component in QML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "haptics.h" | |
#ifdef Q_OS_SYMBIAN | |
#include <QFeedbackEffect> | |
QTM_USE_NAMESPACE | |
#endif | |
Haptics::Haptics(QObject *parent) : | |
QObject(parent) | |
{ | |
} | |
void Haptics::buttonClick() { | |
#ifdef Q_OS_SYMBIAN | |
QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBasicButton); | |
#endif | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef HAPTICS_H | |
#define HAPTICS_H | |
#include <QObject> | |
class Haptics : public QObject | |
{ | |
Q_OBJECT | |
public: | |
explicit Haptics(QObject *parent = 0); | |
signals: | |
public slots: | |
void buttonClick(); | |
}; | |
#endif // HAPTICS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
property int hitboxExtension : 10 | |
// Yadda yadda | |
MouseArea { | |
id: hitbox | |
anchors.fill: parent | |
anchors.topMargin: -hitboxExtension | |
anchors.bottomMargin: -hitboxExtension | |
anchors.leftMargin: -hitboxExtension | |
anchors.rightMargin: -hitboxExtension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Haptics haptics; | |
QDeclarativeView w; | |
QDeclarativeEngine* engine = w.engine(); | |
engine->rootContext()->setContextProperty("haptics", &haptics); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Qt 4.7 | |
Rectangle { | |
width: 360 | |
height: 640 | |
color: "#444444" | |
Button { | |
id: selectButton | |
anchors.left: parent.left | |
anchors.leftMargin: 30 | |
anchors.right: parent.right | |
anchors.rightMargin: 30 | |
anchors.bottom: quitButton.top | |
anchors.bottomMargin: 20 | |
text: "Select person" | |
onClicked: { proxyItem.sourceItem = picker; proxyItem.grabImage(); } | |
} | |
Button { | |
id: quitButton | |
anchors.left: parent.left | |
anchors.leftMargin: 30 | |
anchors.right: parent.right | |
anchors.rightMargin: 30 | |
anchors.bottom: parent.bottom | |
anchors.bottomMargin: 30 | |
text: "Exit" | |
onClicked: Qt.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment