Skip to content

A rotatable button for Qt in C++ since QPushButtons cant be rotated without some stupid trickery

Notifications You must be signed in to change notification settings

ChaosTheChaotic/QtRotatableButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

QtRotatableButton

A rotatable button for Qt in C+ since QPushButtons cant be rotated without some stupid trickery

Adding

To add this to your Qt project just create new files and paste the code in. Then go to your CMakeLists.txt and add the files to qt_add_executable. I have no idea how to do this for qmake as I have only very recently started using qt.

Usage

Just add the button like you would add a QPushButton and use it like one. To rotate it, make use of QPropertyAnimation. This always rotates the button around its center point.

Simple snippet

The below snippet simply rotates the button by 45 degrees.

auto *rotationAnim = new QPropertyAnimation(button, "rotation");
rotationAnim->setDuration(200);
rotationAnim->setStartValue(0);
rotationAnim->setEndValue(45);
rotationAnim->start(QAbstractAnimation::DeleteWhenStopped);

About

A rotatable button for Qt in C++ since QPushButtons cant be rotated without some stupid trickery

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages