1) Does API class inherit QObject? If yes, it would be better to create signal in it. fro example, timeCahnged(double), and your code will like this:
myClass::myClass()
{
myapi = new API;
connect (myapi, SIGNAL ( timeCahnged(double) ), mylabel, SLOT (setNum(double) ) );
}
myClass::myClass()
{
myapi = new API;
mylabel = new QLabel;
connect (myapi, SIGNAL ( timeCahnged(double) ), mylabel, SLOT (setNum(double) ) );
}
To copy to clipboard, switch view to plain text mode
2) Set value by QTimer
myClass::myClass()
{
myapi = new API;
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
}
int myClass::runapi()
{
// init API
timer->start(1000);
}
void myClass::update ()
{
mylabel->setNum(myapi->mymethodelapsedtime());
}
myClass::myClass()
{
myapi = new API;
mylabel = new QLabel;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
}
int myClass::runapi()
{
// init API
timer->start(1000);
}
void myClass::update ()
{
mylabel->setNum(myapi->mymethodelapsedtime());
}
To copy to clipboard, switch view to plain text mode
Bookmarks