Qt로 GUI에서 작업하고 있는데 스레드로 게임하는 데 문제가 있습니다. 나는 두 개의 버튼 스트림과 stopstream을 가진 작은 GUi를 생성한다. 아래 코드의 일부입니다 : 내 문제는 내가 그것을을 stoping 후 스트림을 다시 시작할 수 있다는 것입니다 이것은 당신의 stream
개체의 소멸자를 호출Qt : 스레드 다시 시작
MainThread::MainThread(QWidget *parent):QWidget(parent){
bstream = new QPushButton("&stream");
bstopstream = new QPushButton("STOP stream");
bcapture = new QPushButton("capture a frame");
Allbox = new QVBoxLayout(this);
Allbox->addWidget(bstream);
Allbox->addWidget(bcapture);
Allbox->addWidget(bstopstream);
connect(bstream,SIGNAL(clicked()),this, SLOT(startingstream()));
connect(bcapture,SIGNAL(clicked()),this, SLOT(captureAFrame()));
connect(bstopstream,SIGNAL(clicked()),this, SLOT(stopstreaming()));
setLayout(Allbox);
}
void MainThread::stopstreaming(){
cv::destroyAllWindows();
stream.terminate();
stream.wait();
stream.~Streaming();
}
void MainThread::startingstream(){
if(stream.isRunning()) return;
stream.start();
}
유사한 프로그램의 경우 방금 스레드를 다시 시작하여 다시 시작합니다. 제 경우에는 스트림으로 가지고있는 것이 스마트 포인터였습니다. – drescherjm
또한 메모리 누수 및 변수의 부분 업데이트와 같은 다른 나쁜 동작이 발생할 수 있기 때문에 문서에서 권장하지 않습니다 ... – drescherjm
당신의 의미가 미안합니다. – Engine