So, I make this connection of a timer:
main.cpp:
connect(this, SIGNAL(timeout()), Global, SLOT(connected_to_internet()));
connect(this, SIGNAL(timeout()), Global, SLOT(connected_to_internet()));
To copy to clipboard, switch view to plain text mode
which is done inside the class of itself (that's why the 'this' in the 1st argument).
Now, I want to connect this timer with a static bool function called connected_to_internet() declared in a header file like this:
glob.h:
class Global{
public:
static bool connected_to_internet(){
params << "-c" << "1" << "www.google.com";
connected->start(exec,params);
if(!connected->waitForFinished())
return false;
int exitcode=connected->exitCode();
delete connected;
if(!exitcode){
qDebug() << "CONNECTED!\n";
return true;
}
else{
qDebug() << "NOT CONNECTED!\n";
return false;
}
}
};
class Global{
public:
static bool connected_to_internet(){
QProcess *connected = new QProcess(0);
QString exec="ping";
QStringList params;
params << "-c" << "1" << "www.google.com";
connected->start(exec,params);
if(!connected->waitForFinished())
return false;
int exitcode=connected->exitCode();
delete connected;
if(!exitcode){
qDebug() << "CONNECTED!\n";
return true;
}
else{
qDebug() << "NOT CONNECTED!\n";
return false;
}
}
};
To copy to clipboard, switch view to plain text mode
Do I do anything wrong here?
The compiler complains about the connection I do that:
/home/alex/Workstation/test-build-desktop/../test-1.0/main.cpp:263: error: expected primary-expression before ‘,’ token
/home/alex/Workstation/test-build-desktop/../test-1.0/main.cpp:263: error: expected primary-expression before ‘,’ token
To copy to clipboard, switch view to plain text mode
Bookmarks