c++ - Undefined reference for a static QStringList -


so, want create "recent files" section in "file menu" of spreadsheet application. while building application, function supposed update recentfileactions qstringlist generates following error/home/axel/qtsdk/code/qmainwindow/mainwindow.cpp:-1: error: undefined reference 'mainwindow::recentfiles'

so error recentfiles isn't defined? because have in private section of header: qstringlist static recentfiles;

this whole updaterecentfileactions() function:

void mainwindow::updaterecentfileactions(){   qmutablestringlistiterator i(recentfiles);   while (i.hasnext()) {     if (!qfile::exists(i.next()))         i.remove();   }    (int j = 0; j < maxrecentfiles; ++j) {     if (j < recentfiles.count()) {         qstring text = tr("&%1 %2")         .arg(j + 1)         .arg(strippedname(recentfiles[j]));         recentfileactions[j]->settext(text);         recentfileactions[j]->setdata(recentfiles[j]);         recentfileactions[j]->setvisible(true);     } else {         recentfileactions[j]->setvisible(false);     }   }   separatoraction->setvisible(!recentfiles.isempty()); } 

i'll add missing information.

thank you.

qstringlist static recentfiles; 

that declaration. need define static variable in source file :

qstringlist mainwindow::recentfiles; 

if not understand why need it, take see this faq item.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -