Neil, Looks good, but you'll have less trouble with memory leaks if you use a WString instead of a pointer to a WString in the example.
Wim. 2010/11/1 Neil DSouza <[email protected]>: > Dmitriy Igrishin <dmit...@...> writes: > >> >> >> Hey Neil,One solution is to use WSignalMapper class.Another solution is to > make some methods which providesinformation about selected rows and call them > from the slotconnected to you WPushButton clicked signal. > > Hi Dmitriy, > > Thanks for the quick response - I saw the reply yesterday and wanted to > post the example below last night - but internet connection kept dropping > every > few 30 secs for some reason. > > Here is the "hello" example that works based on what you suggested. > > Kind Regards, > Neil > > > > #include <Wt/WApplication> > #include <Wt/WBreak> > #include <Wt/WContainerWidget> > #include <Wt/WLineEdit> > #include <Wt/WPushButton> > #include <Wt/WText> > #include <Wt/WString> > #include <Wt/WSignalMapper> > > using namespace Wt; > > class HelloApplication : public WApplication > { > public: > HelloApplication(const WEnvironment& env); > > private: > WLineEdit *nameEdit_; > WText *greeting_; > > void greetWithData(Wt::WString * data); > }; > > HelloApplication::HelloApplication(const WEnvironment& env) > : WApplication(env) > { > setTitle("Hello world"); // application title > > root()->addWidget(new WText("Your name, please ? ")); // show some text > nameEdit_ = new WLineEdit(root()); // allow text input > nameEdit_->setFocus(); // give focus > > WPushButton *b = new WPushButton("Greet me.", root()); // create a button > b->setMargin(5, Left); // add 5 pixels margin > > root()->addWidget(new WBreak()); // insert a line break > > greeting_ = new WText(root()); // empty text > > Wt::WSignalMapper<Wt::WString*> *myMap = new > Wt::WSignalMapper<Wt::WString > *>(this); > myMap->mapped().connect(this, &HelloApplication::greetWithData); > myMap->mapConnect(b->clicked(), new WString(" 1 2 3 4 = some sample > data")); > > } > > void HelloApplication::greetWithData(Wt::WString * data) > { > greeting_->setText("Hello there, " + nameEdit_->text() + > " here is the data: " + *data); > } > > WApplication *createApplication(const WEnvironment& env) > { > return new HelloApplication(env); > } > > int main(int argc, char **argv) > { > return WRun(argc, argv, &createApplication); > } > > > > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > witty-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/witty-interest > ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
