我在主窗口上有Qlabel小部件(对象名= label_2)。我在这个小部件上显示来自摄像头的实时信息。一切都很好。但是我想知道如何改变实时饲料的方向(比方说我想将它翻转90°)。
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras)
{
if (cameraInfo.deviceName() == "@device:pnp:\\\\?\\pci#ven_109e&dev_036e&subsys_00000000&rev_11#5&12a6b002&0&000008#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global")
cM2 = new QCamera(cameraInfo, this);
}
cV2 = new QCameraViewfinder(this);
cM2->setViewfinder(cV2);
cBox2 = new QVBoxLayout();
cBox2->addWidget(cV2);
ui->label_2->setLayout(cBox2);
cM2->start();
答案 0 :(得分:0)
QCameraViewfinder不会旋转,因此使用QGraphicsVideoviewer可能会提供更好的服务。
类似的东西:
#include <QGraphicsVideoItem>
videoItem = new QGraphicsVideoItem;
videoItem->setSize(QSizeF(640, 480));
GraphicsScene *scene = new QGraphicsScene(this);
QGraphicsView *graphicsView = new QGraphicsView(scene);
scene->addItem(videoItem);
cM2->setViewfinder(videoItem);
videoItem->setTransform(QTransform().rotate(90));
cBox2->addWidget(graphicsView);