如何在布局中安排 QCamera 与其他小部件?
How to arrange QCamera with other widgets in a layout?
这是关于安排带有小部件的多媒体对象。
以下是我尝试过的:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
m_QPushButton_calibration = new QPushButton("Calibrate", this);
connect(m_QPushButton_calibration, SIGNAL (released()),this, SLOT (handleButton()));
QList<QCameraInfo> l_QListQCameraInfo_available_cameras = QCameraInfo::availableCameras();
if (l_QListQCameraInfo_available_cameras.length() > 2)
{
m_QCamera_required_camera = new QCamera (l_QListQCameraInfo_available_cameras[1]);
}
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(m_QPushButton_calibration);
layout->addWidget(m_QCamera_required_camera);
this->setLayout(layout);
}
结果是:
error: no matching function for call to 'QHBoxLayout::addWidget(QCamera*&)'
layout->addWidget(m_QCamera_required_camera);
^
如何在布局中将 QCamera 与其他小部件一起排列?
QCamera 本身不是一个小部件!但是从 the qt doc 我们了解到:
"QCamera can be used with QCameraViewfinder for viewfinder display, QMediaRecorder for video recording and QCameraImageCapture for image taking."
所以我猜你想要的可能是 QCameraViewfinder:
QCameraViewfinder* cameraView = new QCameraViewfinder (this);
cameraView->setMediaObject (m_QCamera_required_camera);
layout->addWidget(cameraView);
QCamera
不是小部件,您应该使用 QCameraViewfinder
(将多媒体小部件添加到 .pro):
QCameraViewfinder *mCameraViewfinder = new QCameraViewfinder(this);
m_QCamera_required_camera->setViewfinder(mCameraViewfinder);
layout->addWidget(m_QPushButton_calibration);
layout->addWidget(mCameraViewfinder);
m_QCamera_required_camera->start();
这是关于安排带有小部件的多媒体对象。 以下是我尝试过的:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
m_QPushButton_calibration = new QPushButton("Calibrate", this);
connect(m_QPushButton_calibration, SIGNAL (released()),this, SLOT (handleButton()));
QList<QCameraInfo> l_QListQCameraInfo_available_cameras = QCameraInfo::availableCameras();
if (l_QListQCameraInfo_available_cameras.length() > 2)
{
m_QCamera_required_camera = new QCamera (l_QListQCameraInfo_available_cameras[1]);
}
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(m_QPushButton_calibration);
layout->addWidget(m_QCamera_required_camera);
this->setLayout(layout);
}
结果是:
error: no matching function for call to 'QHBoxLayout::addWidget(QCamera*&)'
layout->addWidget(m_QCamera_required_camera);
^
如何在布局中将 QCamera 与其他小部件一起排列?
QCamera 本身不是一个小部件!但是从 the qt doc 我们了解到:
"QCamera can be used with QCameraViewfinder for viewfinder display, QMediaRecorder for video recording and QCameraImageCapture for image taking."
所以我猜你想要的可能是 QCameraViewfinder:
QCameraViewfinder* cameraView = new QCameraViewfinder (this);
cameraView->setMediaObject (m_QCamera_required_camera);
layout->addWidget(cameraView);
QCamera
不是小部件,您应该使用 QCameraViewfinder
(将多媒体小部件添加到 .pro):
QCameraViewfinder *mCameraViewfinder = new QCameraViewfinder(this);
m_QCamera_required_camera->setViewfinder(mCameraViewfinder);
layout->addWidget(m_QPushButton_calibration);
layout->addWidget(mCameraViewfinder);
m_QCamera_required_camera->start();