c++ - Demo program error: '' was not declared in this scope -
i new qt , have started demo program found here. have renamed class addressbook dialog. compiles , executes fine. want add own code example, add new label private member of class:
private: qcheckbox *native; qlabel *integerlabel; qlabel *doublelabel; qlabel *itemlabel; ... qlabel *questionlabel; qlabel *warninglabel; qlabel *errorlabel; qlabel *newlabel; // <== new qerrormessage *errormessagedialog;
in constructor dialog::dialog (try to) allocate memory variables:
warninglabel = new qlabel; warninglabel->setframestyle(framestyle); qpushbutton *warningbutton = new qpushbutton(tr("qmessagebox::&warning()")); errorlabel = new qlabel; errorlabel->setframestyle(framestyle); qpushbutton *errorbutton = new qpushbutton(tr("qerrormessage::showm&essage()")); newlabel = new qlabel; // <== error newlabel->setframestyle(framestyle);
as far can tell, have created , allocated variable correctly in class, copy , pasting *errorlabel , changing name. yet compiler issues error:
error: 'newlabel' not declared in scope
when click error, takes me "new" line in constructor. if remark out 2 lines in constructor referring newlabel, program compiles. in scope in mind. mistake making here? how prevent these type issues in future? (i have searched tens of similar posts , able identify op's mistake in 30s or less, cannot find own, nor can find post variables declared in class, not found in constructor.)
thanks in advance, kyle
i have solved problem. though not answer expected, post answer in case helpful rest of community.
i created new project , copied cpp/h files non-working project new project. new project compiles. new project can add other private variables class , access them in constructor (as ide). parameters have easy access show projects identical, yet 1 compiles , other not. can conclude project somehow became corrupted (which not inspire confidence).
while relieved not stupid programmatic mistake on part, disappointed in not being able find , fix whatever wrong project files. offered suggestions.
Comments
Post a Comment