class xxPlayer : public QThread
{
//Q_OBJECT
public:
。。。。。。。。。。。。。
signals:
void sig_StateChanged(xxPlayer::PlayerState state);
void sig_TotalTimeChanged(qint64 uSec); //获取到视频时长的时候激发此信号
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void slotTotalTimeChanged(qint64 uSec);
void slotStateChanged(xxPlayer::PlayerState state);
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_Player = new xxPlayer(this);
connect(m_Player,SIGNAL(sig_TotalTimeChanged(qint64)),this,SLOT(slotTotalTimeChanged(qint64)));
connect(m_Player,SIGNAL(sig_StateChanged(xxPlayer::PlayerState)),this,SLOT(slotStateChanged(xxPlayer::PlayerState)));
}
void xxPlayer::run()
{
。。。。。。。。。。。。。。。。。。。
emit sig_StateChanged(Playing);
return;
{
//Q_OBJECT
public:
。。。。。。。。。。。。。
signals:
void sig_StateChanged(xxPlayer::PlayerState state);
void sig_TotalTimeChanged(qint64 uSec); //获取到视频时长的时候激发此信号
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void slotTotalTimeChanged(qint64 uSec);
void slotStateChanged(xxPlayer::PlayerState state);
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_Player = new xxPlayer(this);
connect(m_Player,SIGNAL(sig_TotalTimeChanged(qint64)),this,SLOT(slotTotalTimeChanged(qint64)));
connect(m_Player,SIGNAL(sig_StateChanged(xxPlayer::PlayerState)),this,SLOT(slotStateChanged(xxPlayer::PlayerState)));
}
void xxPlayer::run()
{
。。。。。。。。。。。。。。。。。。。
emit sig_StateChanged(Playing);
return;
}
报错信息如下:
不加报的错
加上报错:
问题原因:
用信号必须要加上Q_OBJECT
去掉后还报错,将所有中间文件(临时文件等)删除后重新编译。