Place viewfinder widget into main window.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Jul 2017 20:09:36 +0000 (22:09 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 5 Jul 2017 20:09:36 +0000 (22:09 +0200)
qtapp/barcode2cash/mainwindow.cpp
qtapp/barcode2cash/mainwindow.h
qtapp/barcode2cash/mainwindow.ui

index fdc6847109b725be78d939d5b864fbd775ead56f..800836dd52fcee504ef37e427731ab77da69b570 100644 (file)
@@ -19,9 +19,7 @@ MainWindow::MainWindow(QWidget *parent) :
     if (!info.isNull()) {
         camera = new QCamera(info);
         camera->setCaptureMode(QCamera::CaptureStillImage);
-        viewfinder = new QCameraViewfinder;
-        camera->setViewfinder(viewfinder);
-        viewfinder->show();
+        camera->setViewfinder(ui->viewFinder);
         imageCapture = new QCameraImageCapture(camera);
         connect(imageCapture, SIGNAL(readyForCaptureChanged(bool)), SLOT(updateCameraInfo()));
         connect(imageCapture, SIGNAL(imageSaved(int,QString)), SLOT(showCaptureSuccess(int,QString)));
@@ -38,7 +36,6 @@ MainWindow::MainWindow(QWidget *parent) :
 
 MainWindow::~MainWindow() {
     delete imageCapture;
-    delete viewfinder;
     delete camera;
     delete ui;
 }
index 4344d1ebf65a7fe27155e57cd2c6e19c1aae0dff..51be7912a3c3db01ae60aa5c513f0bb077c0d0c7 100644 (file)
@@ -23,7 +23,6 @@ private:
     Ui::MainWindow *ui;
 
     QCamera* camera = nullptr;
-    QCameraViewfinder* viewfinder = nullptr;
     QCameraImageCapture* imageCapture = nullptr;
 
 public slots:
index a73edd65a424235dd975a3bfdbb1764ed35fb99c..76c4ab218a7597af9bec325f2563389563805d9e 100644 (file)
      <string>TextLabel</string>
     </property>
    </widget>
+   <widget class="QCameraViewfinder" name="viewFinder" native="true">
+    <property name="geometry">
+     <rect>
+      <x>80</x>
+      <y>80</y>
+      <width>251</width>
+      <height>161</height>
+     </rect>
+    </property>
+   </widget>
   </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
   <widget class="QStatusBar" name="statusBar"/>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+  <customwidget>
+   <class>QCameraViewfinder</class>
+   <extends>QWidget</extends>
+   <header>qcameraviewfinder.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>