我正在编写一个使用QDialog作为主窗口的应用程序。在这个应用程序中,我有3个QGroupBox,一个带有几个按钮,第二个带有一个显示网络摄像头内容的GLWidget(使用OpenCV捕获和处理并用OpenGL显示),第三个我试图用Phonon播放不同的视频我打算使用QComboBox选择视频,但这与我的问题无关)。声音:: VideoWidget在QDialog中的问题
一切正常,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来重现问题,并将其编译和没有问题的作品,所以应该有一些与声子发生冲突。我认为它可能是GLWidget,但我断开了GUI的这一部分...并且它仍然会杀死线程。
有人遇到过类似的问题吗?有人对任何可能出错或如何检查线程杀死有任何了解吗?
您是否创建了声子路径? – 2011-03-02 10:04:14
嗨卡米尔,我不能。当我包括该行: Phonon :: VideoWidget * _player_video = new Phonon :: VideoWidget; 所有QT线程在代码1之后立即退出。 PS:我想你是在谈论Phonon :: createPath方法。 – sergi 2011-03-02 16:48:16