Qtimer on tabs of QTabWidget... not updating?
-
Hello,
I'm using a simple QTimer to update some visual widgets potentially on multiple tabs / forms on a QTabWidget. I assume the QTimer should continue to run and update the widgets even when the tab is not the actively displayed tab. Am I assuming wrong? Does the tab being set to inactive (selecting a different tab) somehow pause of deactivate the QTimer? ...or keep it from updating widgets? A separate QTimer is instantiated as a member with each separately constructed tab form class, so, I'm pretty confident there are separate instances of QTimer per tab.
Simple QTimer setup code below is launched by a push button on each tab form. Any insight is greatly appreciated.
# Start input processing timer self.timerTagXformData = QTimer(self) self.timerTagXformData.timeout.connect(txform.processInputFile) self.timerTagXformData.start(self._PROCESS_INPUT_DATA_INTERVAL_MILLI)
-
Hi
QTimer continues to run regardless of the widgets.
however, the widget/object having the slot must remain allocated.
so txform.processInputFile must live when you switch to other tab. I assume it
a tab(Widget) ?
However, if Widget is not shown, any updates might not have effect before switching to the
tab.
Try to set a break point in processInputFile to veryfy its still called even if on other tab. -
Hi
QTimer continues to run regardless of the widgets.
however, the widget/object having the slot must remain allocated.
so txform.processInputFile must live when you switch to other tab. I assume it
a tab(Widget) ?
However, if Widget is not shown, any updates might not have effect before switching to the
tab.
Try to set a break point in processInputFile to veryfy its still called even if on other tab.@mrjj Thank you for confirming! I will debug this and confirm. I suspect I am simply witnessing a delay in updating the widgets when a tab is reselected and made active, and the background QTimer is fine and continuously running. I will follow-up asap.
-
@mrjj Thank you for confirming! I will debug this and confirm. I suspect I am simply witnessing a delay in updating the widgets when a tab is reselected and made active, and the background QTimer is fine and continuously running. I will follow-up asap.
@David-Jacobson
Hi
On fix could be to to hook to
http://doc.qt.io/qt-5/qtabwidget.html#currentChanged
and do a manual update() to ensure that last Timer change is drawn.
I assume the timers alters the data and Page is ok as soon as timer fires again so
the issue is seen when switching to tab in between timer firing ? -
@David-Jacobson
Hi
On fix could be to to hook to
http://doc.qt.io/qt-5/qtabwidget.html#currentChanged
and do a manual update() to ensure that last Timer change is drawn.
I assume the timers alters the data and Page is ok as soon as timer fires again so
the issue is seen when switching to tab in between timer firing ?@mrjj said in Qtimer on tabs of QTabWidget... not updating?:
he timers alters the data and Page is ok as soo
Yep, I'm pretty sure that's what is happening too... confirming with my user that it is just a delay and not something more serious. These are"delayed" widget updates on a timer interval anyways (when active), so, I suspect the switching between multiple tabs that all happen to have started background QTimers might be emphasizing the widget update delay to the user.
-
@mrjj said in Qtimer on tabs of QTabWidget... not updating?:
he timers alters the data and Page is ok as soo
Yep, I'm pretty sure that's what is happening too... confirming with my user that it is just a delay and not something more serious. These are"delayed" widget updates on a timer interval anyways (when active), so, I suspect the switching between multiple tabs that all happen to have started background QTimers might be emphasizing the widget update delay to the user.
@David-Jacobson
Hi
Well if a widget is not shown
http://doc.qt.io/qt-5/qwidget.html#visible-prop
returns false, there is really no reason to redraw on screen as
its just wasted efforts. ( as doc talks about)
I think this is what you are seeing.