Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900