Skip to content

Instantly share code, notes, and snippets.

@dridk
Created October 24, 2012 23:01
Show Gist options
  • Save dridk/3949483 to your computer and use it in GitHub Desktop.
Save dridk/3949483 to your computer and use it in GitHub Desktop.
C++ mode
// 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