Hi Massimo. The error means that it cannot recognize the 'chart' object in your function. The compiler does not know which object you are referring to.
The 'chart' object is created in the CategoryExample by this line: WCartesianChart *chart = new WCartesianChart(this); for you to access this object in your function you need to do two things: First, declare it in the header file of CategoryExample like this: WCartesianChart *chart; then change the line in the CategoryExample constructor from WCartesianChart *chart = new WCartesianChart(this); to chart = new WCartesianChart(this); Now the object belongs to CategoryExample and can be accessed by all its functions. Then you need clear up some confusion in your function: Currently your function belongs to ChartsExample stated by this line void ChartsExample::printG() which should be void CategoryExample::printG() in order to access the 'chart' object. (your button.connect-reference is correct though...) I think it should work if you make these changes. I could not spot any more errors on the fly :) Good luck learning Wt! -Magnus On 15/05/2012 23:39, Massimo Di Stefano wrote: > Hi All, > > > please apologize me for the newbie question and for my bad attempt to > explain what i'm bring to do. > > i'm starting from the WT chart example to make a web app to display data > from a csv file. > > the code is : > > http://epifanio.whoi.edu/web/ChartsExample.C > > at the end of the file this lines of code : > > Wt::WSvgImage svgImage(800, 400); > Wt::WPainter p(&svgImage); > chart->paint(p); > p.end(); > std::ofstream f("chart.svg"); > svgImage.write(f); > > > save the chart as SVG, but it is executed when the app is loaded. > > .. i'm tring to learn how to call and execute that code using a Wtbutton > > So i moved it in a method : > > void ChartsExample::printG() > { > Wt::WSvgImage svgImage(800, 400); > Wt::WPainter p(&svgImage); > chart->paint(p); > p.end(); > std::ofstream f("chart.svg"); > svgImage.write(f); > } > > > then i added a button and connected it to that method : > > > ChartsExample::ChartsExample(WContainerWidget *root) > : WContainerWidget(root) > { > new WText(WString::tr("introduction"), this); > > new CategoryExample(this); > Wt::WPushButton *button = new Wt::WPushButton("PrintG", root); > button->clicked().connect(this, &CategoryExample::printG); > > } > > > the make fail with the error : > > dev/src/wt-3.2.0/examples/charts/ChartsExample.C: In member function > ‘void ChartsExample::printG()’: > dev/src/wt-3.2.0/examples/charts/ChartsExample.C:212:5: error: ‘chart’ > was not declared in this scope > > my lack of knowledge in C++ doesn't allow me to understand how to pass > the object 'chart' to that method, please have you any hints ? > > thanks!!! > > Massimo. > > > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > > > _______________________________________________ > witty-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/witty-interest ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
