Created
October 24, 2012 23:01
-
-
Save dridk/3949483 to your computer and use it in GitHub Desktop.
C++ mode
This file contains 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
// Create the root page and the button | |
Page* root = new Page; | |
Button* myButton = Button::create("My Rotating Button"); | |
// Create a rotation animation and associate it with the button | |
RotateTransition* rotation = RotateTransition::create(myButton) | |
.toAngleZ(360) | |
.duration(350); | |
// Connect the button's clicked() signal to the animation's play() slot, so that | |
// when the button is clicked, the animation plays. Make sure to test the return | |
// value to detect any errors. | |
bool res = QObject::connect(myButton, SIGNAL(clicked()), rotation, SLOT(play())); | |
Q_ASSERT(res); | |
// Indicate that the variable res isn't used in the rest of the app, to prevent | |
// a compiler warning | |
Q_UNUSED(res); | |
// Set the content of the page and display it | |
root->setContent(myButton); | |
app->setScene(root); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment