This is the source code:
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <QTimer>
using namespace std;
time_t seconds;
seconds = time (NULL); //EROR No1
connect(timer, SIGNAL(timeout()), this, SLOT(update_time())); //ERROR No3
int main ()
{ timer->start(1000);
return 0;
}
void update_time()
{
int a=1;
while(a){
time_t seconds;
seconds = time (NULL);
cout << "Seconds = " << seconds << endl;}
}
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <QTimer>
using namespace std;
time_t seconds;
seconds = time (NULL); //EROR No1
QTimer *timer = new QTimer(this); //ERROR No2
connect(timer, SIGNAL(timeout()), this, SLOT(update_time())); //ERROR No3
int main ()
{ timer->start(1000);
return 0;
}
void update_time()
{
int a=1;
while(a){
time_t seconds;
seconds = time (NULL);
cout << "Seconds = " << seconds << endl;}
}
To copy to clipboard, switch view to plain text mode
As you understood I wanna have the system time in secs since 1/1/1970 and to be updated every 1 sec...
Unfortunately I get plenty of errors:
7: error: expected constructor, destructor, or type conversion before ‘=’ token
8: error: invalid use of ‘this’ at top level
9: error: expected constructor, destructor, or type conversion before ‘(’ token
7: error: expected constructor, destructor, or type conversion before ‘=’ token
8: error: invalid use of ‘this’ at top level
9: error: expected constructor, destructor, or type conversion before ‘(’ token
To copy to clipboard, switch view to plain text mode
thank you for any replies!
Bookmarks