PDA

View Full Version : Global Variables till restart



NTMS
19th December 2015, 08:37
Hi,

I have mainWindow.cpp and DialogWifi.cpp

In DialogWifi.cpp I connect to wifi. If connection successful I want to set once the global variable like globalShowWifiIcon and globalWifiConnect.
So I created separate globals.h and put the global variable as;

globals.h


#ifndef GLOBALS
#define GLOBALS

namespace globals
{
// forward declarations only
extern bool globalShowWifiIcon;
extern bool globalWifiConnect;
}

#endif // GLOBALS


In DialogWifi.cpp I try to set as;

globals::globalShowWifiIcon = true;
globals::globalWifiConnect = true;

Then in MainWindow.cpp

if(globals::globalShowWifiIcon == false)
{
ui->labelLogo->setPixmap(QPixmap("/home/root/res/button/wifiOff.png"));
}
else
{
ui->labelLogo->setPixmap(QPixmap("/home/root/res/button/wifi.png"));
}

In mainWindow.cpp and DialogWifi.cpp I incluede as;

#include "globals.h"

When I compile I am getting error as;

error: undefined reference to `globals::globalShowWifiIcon'

Any help please,

Kind Regards,