大家好,我想利用全局变量实现两个窗口之间的数据传递:比如说利用ID和Password登陆以后登陆窗口关闭,但是我想保存ID的信息在新窗口中继续使用,于是我定义globalUnit类:
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QtGui>
class globalUnit
{
public:
static QString currentUser;
};
#endif // GLOBAL_H
在loginwindow.cpp中包含这个头文件,然后在该cpp下对currentUser赋值:globalUnit::currentUser=ui->IDEdit->text();
编译报错:
Undefined symbols:
"globalUnit::currentUser", referenced from:
__ZN10globalUnit11currentUserE$non_lazy_ptr in loginwindow.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
不知道是什么问题?谢谢