Skip to content

Instantly share code, notes, and snippets.

@xlarsx
Created April 29, 2011 18:43
Show Gist options
  • Save xlarsx/948788 to your computer and use it in GitHub Desktop.
Save xlarsx/948788 to your computer and use it in GitHub Desktop.
QT Transformation Widget
## Ref: http://www.qtcentre.org/threads/27130-Rotate-QGraphicsProxyWidget-in-QGraphicsView
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsView gv;
QGraphicsScene scene(-200,-200,400,400);
gv.setScene(&scene);
gv.setRenderHint(QPainter::Antialiasing);
gv.setDragMode(QGraphicsView::ScrollHandDrag);
QWidget wi;
QVBoxLayout lo;
QPushButton btn("My Button", &wi);
lo.addWidget(&btn);
wi.setLayout(&lo);
QGraphicsProxyWidget *pw = scene.addWidget(&wi);
pw->setPos(0, 0);
pw->setRotation(-20);
gv.show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment