QWidget旋转
代码:
#include <QApplication> #include <QGraphicsView> #include <QGraphicsProxyWidget> #include "./form.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); Form *form = new Form; //项目主窗口 QGraphicsScene *scene = new QGraphicsScene; QGraphicsProxyWidget *w = scene->addWidget(form); w->setRotation(90); QGraphicsView *view = new QGraphicsView(scene); view->resize(810, 610); //旋转之后,在arm上设置的尺寸未生效,比设置尺寸小,使用view->shouwFullScreen()解决。 view->show(); view->setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff); view->setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff); //关闭滚动条 return a.exec(); }
缺点:
若某个窗口与主窗口没有父子关系,这个窗口没有添加到scene里,那么显示这个窗口时就不会同步转屏。
参考:https://www.cnblogs.com/findumars/p/6374839.html
坚持成就伟大