主要思路是将所有项目界面加载到QGraphicsScene,再进行旋转操作。直接上代码
#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); view->show();
return a.exec();
}
此方法缺点:
若某个窗口与主窗口没有父子关系,这个窗口没有添加到scene里,那么显示这个窗口时就不会同步转屏
http://www.qtcn.org/bbs/read-htm-tid-61185.html