Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-115008

QT 5.15 QML using Camera prompt: Starting camera without viewfinder available

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15
    • Multimedia
    • None
    • Linux/Wayland, Linux/Other display system

      I am using an arm development board for Linux to develop a software. Due to its complex layout, I use QML for layout. When I was using the camera that comes with QML, I found that the preview interface was blank. However, when I ran the code on Windows, it was previewed normally. Is there anything wrong with my development board? Then it is normal for me to preview using Creator, and the following is my code:

      //QML 代码占位符  
      import QtQuick 2.9
      import QtQuick.Controls 2.2
      import QtQuick.Window 2.12
      import QtMultimedia 5.12ApplicationWindow {
          visibility:Window.FullScreen                // Show FullScreen
          visible: true
          width:1920
          height: 1080
          flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint//隐藏标题栏    //图片输出元素
          VideoOutput {
              anchors.fill: parent
              source: camera.imageCapture
          }
              //摄像头元素
          Camera {
            id: camera
            captureMode: Camera.CaptureViewfinder
          
            
            onError: {
              console.log("Camera error:", error)
            }
           
         }}
       

       

       

       

      //Creator 代码占位符
      
      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QCameraInfo>
      #include <QFileDialog>
      #include <QDebug>
      #include <QMessageBox>
      #include <QProcess>
      #include <QTimer>
      #include <QMediaMetaData>MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          showFullScreen();//单纯使用这个也会在运行的时候隐藏一下状态栏,但是点一下鼠标就又出现了
          setMaximumSize(1280, 720);
          // 去掉标题栏,去掉任务栏显示,窗口置顶
          this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);    QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
          if(cameras.count() > 0){
              camera = new QCamera(cameras.at(0));
          }
          viewfinder = new QCameraViewfinder(this);
          camera->setViewfinder(viewfinder);
          viewfinder->resize(600,600);
          imageCapture = new QCameraImageCapture(camera);
          camera->start();
      }MainWindow::~MainWindow()
      {
          delete ui; 
      } 

       

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            laknoll Lars Knoll
            yumao 沐 应
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes