[thread.cpp]
#include
#include
#include "thread.h"
Thread::Thread()
{
stopped = false;
}
void Thread::setMessage(const QString &message)
{
messageStr = message;
}
void Thread::run()
{
while (!stopped)
::system("mplayer /1.mp3");
// std::cerr << qPrintable(messageStr);
stopped = false;
std::cerr << std::endl;
}
void Thread::stop()
{
stopped = true;
}
==================================================
[thread.h]
#ifndef THREAD_H
#define THREAD_H
#include
class Thread : public QThread
{
Q_OBJECT
public:
Thread();
void setMessage(const QString &message);
void stop();
protected:
void run();
private:
QString messageStr;
volatile bool stopped;
};
#endif
==========================================================
::system(" kill -9 $(pidof mplayer)");
阅读(866) | 评论(0) | 转发(0) |