second
がチャージしたときに音を鳴らそうとしています。Qtでサウンドを設定するには
は私のstopwatch
でmilliseconds
があり、それはmiliseconds'
変更、ないseconds'
ものの下で果たしています。 *seconds*
に対しての条件を作成する必要があります。
しかし、を正しく実行できません。この状態はアドバイスできますか?
私のコンストラクタとスロット:ここ
は私方法(
milliseconds
ためQMediaPlayer
のオブジェクト滞在)である
StopMainWindow::StopMainWindow(QWidget *parent) :
QMainWindow(parent),
mRunning(false)
, mStartTime()
, mTotalTime(0)
{
//ON THE TOP THERE ARE QPUSHBUTTONS AND QLABELS OBJECTS
connect(pushButton_Start, SIGNAL(clicked()), SLOT(start()));
connect(pushButton_go_on, SIGNAL(clicked()), SLOT(pause()));
connect(pushButton_Stop, SIGNAL(clicked()), SLOT(stop()));
connect(pushButton_Close, SIGNAL(clicked()), SLOT(close()));
connect(pushButton_Back,SIGNAL(clicked()),SLOT(back()));
///////////////////////////////////////////////////////////////////////////////
setCentralWidget(centralWidget);
///////////////////////////////////////////////////////////////////////////////////////////////
pushButton_Start->setEnabled(true);
pushButton_go_on->setEnabled(false);
pushButton_Stop->setEnabled(false);
startTimer(0);
}
StopMainWindow::~StopMainWindow()
{}
void StopMainWindow::start(void)
{
pushButton_Start->setEnabled(false);
pushButton_go_on->setEnabled(true);
pushButton_Stop->setEnabled(true);
mStartTime = QDateTime::currentDateTime();
mRunning = true;
QMediaPlayer *music=new QMediaPlayer();
music->setMedia(QUrl("qrc:/sounds/tik.mp3"));
music->play();
}
void StopMainWindow::stop(void)
{
pushButton_Start->setEnabled(true);
pushButton_go_on->setEnabled(true);
pushButton_Stop->setEnabled(false);
mTotalTime = 0;
mRunning = false;
}
void StopMainWindow::pause(void)
{
pushButton_Start->setEnabled(true);
pushButton_go_on->setEnabled(false);
pushButton_Stop->setEnabled(true);
timerEvent(new QTimerEvent(0));
mTotalTime += mSessionTime;
mRunning = false;
}
void StopMainWindow::timerEvent(QTimerEvent *)
{
if(mRunning)
{
mSessionTime = mStartTime.msecsTo(QDateTime::currentDateTime());
qint64 time = mTotalTime + mSessionTime;
time *= 111;
unsigned int h = time/1000/60/60;
unsigned int m = (time/1000/60) - (h * 60);
unsigned int s = (time/1000) - ((m + (h * 60))* 60);
unsigned int ms = time - (s + ((m + (h * 60))* 60)) * 1000;
const QString diff = QString("%1:%2:%3,%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0')).arg(ms, 3, 10, QChar('0'));
mLabel->setText(diff);
}
}
「timerEvent」期間とは何ですか? – eyllanesc
@eyllanescこれは、私のボタン 'countinue'を使って接続するために作成されたものです。 ここに、 'timerEvent'が使用されるSLOTがあります: ' void StopMainWindow :: pause(void) { ** timerEvent **(new QTimerEvent(0)); mTotalTime + = mSessionTime; mRunning = false; } ' – Nikitax
あなたの完全なコードを置くことができますが、これは間違っているようです。 – eyllanesc