Reputation: 9492
I have a PyQT4
application that reads information from a local sqlite3
database and display the data using QTableWidget
.
The data stored on the sqlite3
changes from time to time.So, I want to update my Table Widget once every 1 min.
To simplify matters, let's assume i already have a function called 'Refresh()' that will refresh the contents in my Table Widget.
How do i make this function 'Refresh()' to execute every 1 min? I have done this in Tkinter
using time.after()
. I have no idea how to do it in PyQt
.
Upvotes: 3
Views: 3986
Reputation: 4434
Your function should probably be called paintEvent. Then make a QTimer like so:
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.update)
self.timer.start(60000) #trigger every minute.
That is unless you need to for some reason update something in the backed and not in the front end (in other words the function is not used for drawing. Otherwise it should allmost without question be called paintEvent). Then do:
self.timer.timeout.connect(self.Refresh)
Upvotes: 5