我正在编写一个使用 QDialog 作为主窗口的应用程序。在这个应用程序中,我有 3 个 QGroupBox,一个带有几个按钮,第二个带有显示网络摄像头内容的 GLWidget(使用 OpenCV 捕获和处理并使用 OpenGL 显示),在第三个中我试图使用 Phonon 播放不同的视频(基本上我打算使用 QComboBox 选择视频,尽管这与我的问题无关)。
一切正常,GUI 初始化,做我需要的一切......直到我尝试创建一个 VideoWidget 对象。这是我班的代码:
GUIT::GUIT(QWidget *parent, Qt::WFlags flags)
{
// Initialization of the different QGroupBox
createVideo();
createButtons();
createScoreFE();
createPhonon();
gbScoreFE->hide();
QHBoxLayout *layout = new QHBoxLayout;
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(gbVideo, 0, 0);
mainLayout->addWidget(gbButtons, 1, 0);
mainLayout->addWidget(gbScoreFE, 0, 0);
layout->addLayout(mainLayout);
layout->addWidget(gbPhonon);
gbPhonon->hide();
this->setLayout(layout);
layout->setSizeConstraint(QLayout::SetFixedSize);
}
崩溃的方法是:
void GUIT::createPhonon()
{
gbPhonon = new QGroupBox(tr("Test"));
// This line makes the program to stop executing.
Phonon::VideoWidget *_player_video = new Phonon::VideoWidget;
QVBoxLayout *layout = new QVBoxLayout;
gbPhonon->setLayout(layout);
}
它是如何崩溃的??好吧,它只是在创建一个新的 VideoWidget 后杀死了几个线程。它看起来像:
The thread 'Win32 Thread' (0x12e8) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x1304) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0xf20) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0xdec) has exited with code 1 (0x1).
The thread 'QThread' (0x1e20) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x19b0) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x1f58) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0x1794) has exited with code 1 (0x1).
事实是我对这个问题有点困惑。它出现在我编写 QWidget 时,我将在其中创建 VideoWidget 及其组件......我检查了其他 Phonon 类,初始化它们时 GUI 不受影响。例如:
Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);
我还尝试使用更简单的 GUI 重现该问题,并且它可以毫无问题地编译和工作,因此应该存在与 Phonon 冲突的东西。我认为它可能是 GLWidget,但我断开了 GUI 的这一部分……它仍然会杀死线程。
有人遇到过类似的问题吗?有人对可能出现的问题或如何检查线程终止有任何见解吗?