I'm trying to continuously update a widget to show numbers h:m:s:ms which are returned from a method in another api linked to Qt. That api generally uses a control loop for the method which returns the time elapsed since a method was started. I finally got QLabel to update using my own signal, and repaint, but the time displayed is very slow; much slower than realtime. The float value for the elapsed time looks fine when shown in the console.

Is there a better way to go about this to get an h:m:s:ms display which receives values from another api's method, or is it possible to display updated text in Qt without using a widget? I'm not sure what is causing the slow down.

Qt Code:
  1. //myclass.h
  2. #ifndef MYCLASS_H
  3. #define MYCLASS_H
  4. #include <QWidget>
  5.  
  6. #include "API.hpp"
  7. class QLabel;
  8.  
  9. class myClass : public QWidget
  10. Q_OBJECT
  11. public:
  12. QLabel *mylabel;
  13. double timeVal;
  14. int runapi();
  15. public slots:
  16. void setNum (double num);
  17. signals:
  18. void mySignal(double newnum);
  19. private:
  20. API *myapi;
  21. -----
  22. //myclass.cpp
  23.  
  24. #include "myclass.h"
  25. myClass::myClass()
  26. {
  27. myapi = new API;
  28. mylabel = new QLabel;
  29. connect (this, SIGNAL ( mySignal(double) ), mylabel, SLOT ( setNum(double) ) );
  30. }
  31. int myClass::runapi()
  32. {
  33. while ( myapi->myintreturn() ==0 )
  34. {
  35. timeVal->myapi->mymethodelapsedtime(); //returns double
  36. mylabel->setNum(timeVal);
  37. mylabel->repaint();
  38. }
  39. }
  40. void myClass::setNum (double num)
  41. {
  42. emit mySignal(num);
  43. }
To copy to clipboard, switch view to plain text mode