0

I am planning to make a countdown timer for passes. A file is given from which i read time given as string and then subtract it from the system time to get the time remaining. This value is to be shown in a QTableWidget as a QTableWidgetItem.

How can you update that cell in the table with time?

3 Answers3

1

If you're looking to update the cell every second you could use a QTimer and connect the timeout() signal to your method then Set the timer to 1 second long. This will call your method every second.

I doubt this is the best way to go about this but it's all I've got :)

It should look something like this:

QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(yourFunction()));
timer->start(1000)
0

Use the QTableWidgetItem::setText(...) method after converting your time to a string.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
0

If you want to write hours:minutes, you could compare new result with previous result and if there is a change in time to use QtGui.QApplication.processEvents() which will refresh GUI therefore your time in qtablewidget cell. This might be slow for hours:minutes:seconds

Aleksandar
  • 3,541
  • 4
  • 34
  • 57