I have a variable of QStringList which has some list in Sql.cpp file but I want to use that list in Edit.cpp. How to do that??
in sql.h:
public:
QString path;
static QStringList list;
in sql.cpp ->connectDB() function :
void sql::connectDB()
{
QDir dir;
path=ui->dbpath->text();
dir.setPath(path);
dir.setNameFilters(QStringList()<<"*.db");
list= dir.entryList();
}
When I call entryList , the list of filenames storing in list, a QStringList.
edit.cpp:
void edit::on_pushButton_clicked()
{
SecDialog s;
s.setModal(true);
qDebug()<< sql::list.at(0);
s.exec();
}
i have included sql.h file in edit.cpp file. But I am getting error " Sql.cpp: error: undefined reference to Sql::list" in both files where list is used. Hope u get my problem..