参考原文链接:https://blog.csdn.net/chen9807/article/details/116521928
下面是我的实际运用。
先贴代码
#include "widget.h"
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget form;
QGraphicsScene *scene = new QGraphicsScene;
QGraphicsProxyWidget *w = scene->addWidget(&form);
w->setRotation(270); //设置旋转角度
QGraphicsView *view = new QGraphicsView(scene);
view->resize(1280,720); //设置旋转后的屏幕格式
//设置去除滚动条
view->setRenderHint(QPainter::Antialiasing);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->show();
return a.exec();
}
QT在最后的main函数中添加这段代码即可实现屏幕旋转,调整旋转角度,屏幕尺寸,适配你的开发环境。