multithreading - Qwt Realtime Dial -


i want create simple qwt widget contains dial. value displayed on dial (i.e. position of dial) should updated according input data collect separate thread.

i can generate dial within main window class, , can create , start data capture on separate thread within main window class, this:

mainwindow::mainwindow(qwidget* parent) : qmainwindow(parent) {     // create dial     qdial* pdial = new qdial;      // create data class capture data external source     dataclass* pdata = new dataclass;      // start data class thread     pdata->start();      // can latest value of data @ instant this:     int x = pdata->getdata();      // need connect data value dial,     // dial displays value of data capture device.  } 

what can insert getdata() called update value displayed on dial?

i worked out answer - no idea if it's best way of doing it.

just pass pointer dial constructor of dataclass:

dataclass* pdata = new dataclass(pdial); 

and within dataclass class, include qdial* member , setdialvalue method:

class dataclass { public:     position(qdial* pdial);     .     .     .     void setvalue(int x);  private:      qdial* _pdial;     int _val; } 

set _pdial pointer passed in constructor, , whenever new data received, update dial via setvalue method:

void dataclass::setvalue(int x) {     _pdial->setvalue(x);      return; } 

i've left out mutex locks etc pdial pointer, of course necessary.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -