Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] QTimer /QtabWidget update function not works
Since a couple of days I am struggling to find a way to fix the next problem.
i have a widget that i want to add it to a qTabwidget (this works.)
In the widget that I want to add it to multiple tabs i have a timer that triggers every 2 second a function and is updating some charts.
the problem is next:
i create 2 widget objects from the same class and i add them to 2 tabs. In first tab the graph are working, in the second tab it's not working.
as reference i atach the following code:
monitoringWidget = new StandardWidget();
QScrollArea *area = new QScrollArea();
StandardWidget *widget = new StandardWidget;
QScrollArea *area2 = new QScrollArea(); area2->setWidget(monitoringWidget); QTabWidget *tt = new QTabWidget(); tt->addTab(area, "Tab1"); tt->addTab(area2, "Tab2");
Any sugestion will be very appreciated.
are the widgets (StandardWidget) getting added in both the tabs ?
i create 2 widget objects from the same class and i add them to 2 tabs. In first tab the graph are working, in the second tab it’s not working.
is it the graph, that it is not working in the second tab ?
or addition itself is failing
no errors in the code you've posted.
So there is probably a mistake in the code of your StandardWidget implementation?
Yes the widgets, are both in tab1, respectively tab2 but only in the first tab the graphs are being updated.
in StandardWidget i use this to update the graphs.
@ connect(&dataTimer,SIGNAL(timeout()),this , SLOT(setupRealtimeCpuUserUsagePlot()));
update is fine
there must be some mistake in 'setupRealtimeCpuUserUsagePlot'
the idea is very basic and normaly it works, but when i create a couple objects of that type only 1 graph is working and this is my problem.
i can't figure out where i did wrong...i have tryied using threads but with no luck
if multiple objects are not behaving similarly
you might have used static variables in the function
that is the only possible way for the behaviour
I have found a couple of static variables, i modified them and now it is working correctly.
Thank you ,