This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
51 lines (45 loc) · 1.81 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "captureimage.h"
#include <iostream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QComboBox* cameraSelection = this->findChild<QComboBox*>("cameraOption");
QPushButton* button = this->findChild<QPushButton*>("pushButton") ;
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras) {
cameraSelection->addItem(cameraInfo.description());
}
QComboBox* serialPorts = this->findChild<QComboBox*>("serialport");
ports = QSerialPortInfo::availablePorts();
foreach (const QSerialPortInfo &port, ports){
serialPorts->addItem(port.description());
}
connect(button,SIGNAL(clicked(bool)),this,SLOT(buttonClicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::buttonClicked(){
std::cout << "button clicked" <<std::endl;
QComboBox* cameraSelection = this->findChild<QComboBox*>("cameraOption");
QWidget* cameraVF = this->findChild<QWidget*>("cameraView");
QComboBox* serialSelection = this->findChild<QComboBox*>("serialport");
CaptureImage* cap = new CaptureImage;
cap->cameraNumber = cameraSelection->currentIndex();
cap->myPort = ports.at(serialSelection->currentIndex());
QThread* captureThread = new QThread();
cap->moveToThread(captureThread);
connect(captureThread,SIGNAL(started()),cap,SLOT(process()));
connect(cap, SIGNAL(finished()), captureThread, SLOT(quit()));
connect(cap, SIGNAL(finished()), cap, SLOT(deleteLater()));
connect(captureThread, SIGNAL(finished()), captureThread, SLOT(deleteLater()));
connect(captureThread, SIGNAL(finished()), this, SLOT(updateUI()));
captureThread->start();
}
void MainWindow::updateUI(){
}