我需要一些关于Qtimer使用的帮助.
我使用Qt 5.0.2和我的问题:
我正在尝试开发一个Timer,界面很简单:
只有2个按钮:按钮"开始",启动计时器,"暂停"按钮,以及QtimeEdit显示时间.
此屏幕截图显示了它的外观:http://img834.imageshack.us/img834/1046/5ks6.png
问题是暂停功能不起作用.我在这里阅读了有关Qtimer的所有文档:http://harmattan-dev.nokia.com/docs/library/html/qt4/qtimer.html和这里:qt.developpez.com/doc/5.0-snapshot/qtimer/ ,但没有结果.
这是我的源代码:(我只提供了所需的内容)
// Creation of the Buttons and the time area
void MainWindow::createBottom()
{
bottom = new QWidget();
play = new QPushButton("Launch",this);
pause = new QPushButton("Pause",this);
play->setDisabled(false);
pause->setDisabled(true);
timeEdit = new QTimeEdit(this);
timeEdit->setDisplayFormat("mm:ss");
layout->addWidget(play);
layout->addWidget(pause);
layout->addWidget(timeEdit );
bottom->setLayout(layout);
connect(play, SIGNAL(clicked()), this, SLOT(startSimulation()));
connect(pause, SIGNAL(clicked()), this, SLOT(pauseSimulation()));
}
// to resume the timer where is was stopped
void MainWindow::resumeSimulation()
{
timer->blockSignals( false );
pause->setText("Pause");
pause->disconnect(SIGNAL(clicked()));
connect(pause, SIGNAL(clicked()), this, SLOT(pauseSimulation())); …Run Code Online (Sandbox Code Playgroud)