デジタル時計を作ろうとしています。ただし、私の目的は currentTime() を取得することではありません。代わりに、自分の時間を定義し、そこから時間を増やしています。
ただし、私のコードでは tickSimulation() を呼び出すことはできますが、クロック タイマーは刻み始めません。11:00:00 でスタックします。addSecs(1000) の宣言は正しいですか?
助けてください。ありがとう!
StatusBar::StatusBar()
{
createButtons();
time = new QTime(11, 0, 0);
};
void StatusBar::createButtons()
{
...
lcdSimulation = new QLCDNumber;
lcdSimulation->setNumDigits(8);
simulationTimer = new QTimer;
simulationTimer->start(1000);
QObject::connect(simulationTimer, SIGNAL(timeout()), this, SLOT(tickSimulation()));
addWidget(lcdSimulation);
...
}
void StatusBar::tickSimulation()
{
QString text = time->toString(Qt::TextDate);
if((time->second() % 2) == 0)
text[2] = ' ';
lcdSimulation->display(text);
time->addSecs(1000);
};