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();
m_QCameraViewfinder_viewfinder = new QCameraViewfinder(this);
if (l_QListQCameraInfo_available_cameras.length() >= 2)
{
m_QCamera_required_camera = new QCamera (l_QListQCameraInfo_available_cameras[1]);
m_QCamera_required_camera->setViewfinder(m_QCameraViewfinder_viewfinder);
m_QCamera_required_camera->start ();
}
m_QWidget_central = new QWidget;
m_QGridLayout_main_screen = new QGridLayout;
m_QWidget_central->setStyleSheet ("background-color: green");
m_QWidget_central->setLayout (m_QGridLayout_main_screen);
m_QPushButton_calibration->setStyleSheet ("background-color: pink");
m_QGridLayout_main_screen->addWidget (m_QPushButton_calibration, 0, 0, 1, 1);
m_QCameraViewfinder_viewfinder->setStyleSheet ("background-color: blue");
m_QGridLayout_main_screen->addWidget (m_QCameraViewfinder_viewfinder, 1, 1, 2, 1);
this->setCentralWidget (m_QWidget_central);
m_QCameraViewfinder_viewfinder->show();
}
我试过这个:m_QCameraViewfinder_viewfinder->setStyleSheet ("background-color: blue");
没有帮助。
截至目前尚未安装相机。如何用背景颜色填充QCameraViewFinder?
输出在这里: