如何在qt的计时器中显示数字时间? [英] how to show digit time in a timer in qt?

查看:878
本文介绍了如何在qt的计时器中显示数字时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在QT中创建一个显示分钟,秒和数百秒的计时器。我想在QPlaniTextEdit中显示数字。当我按下start_button时,必须在QPlaintextedit中显示计时器。我写了这段代码,但我不知道如何显示时间以及在插槽中写什么。我的计时器应该工作,直到按下暂停按钮。请帮帮我。



class Mainwindo :: public Mainwidow



Q_OBJECT



public:

显式MainWindow(QWidget * parent = 0);

~MainWindow();

公共位置:



无效on_clicked_start();

私人:



QPushButton *开始;

QPushButton *暂停;

QPlainTextEdit * pl;

QElapsedTimer *时间;

Ui: :MainWindow * ui;

};

connect(start,SIGNAL(clicked()),this,SLOT(on_clicked_start()));

void MainWindow :: on_clicked_start()



{

QString temp;

temp = QString :: number(time-> elapsed());

Myplaintext-> setPlainText(temp);

}

I want to create a timer in QT that shows minutes, seconds and hundreds of a second. I want to show digits in a QPlaniTextEdit. When I push the start_button, there must be timer showed in QPlaintextedit. I wrote this code but I don't know how to show the time and what to write in slot. My timer should be working until the pause button is pushed. Please help me.

class Mainwindo::public Mainwidow

Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:

void on_clicked_start();
private:

QPushButton* start;
QPushButton* pause;
QPlainTextEdit* pl;
QElapsedTimer* time;
Ui::MainWindow *ui;
};
connect(start,SIGNAL(clicked()),this,SLOT(on_clicked_start()));
void MainWindow::on_clicked_start()

{
QString temp;
temp=QString::number(time->elapsed());
Myplaintext->setPlainText(temp);
}

推荐答案

这篇关于如何在qt的计时器中显示数字时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆