Wt C++ Web Toolkit: How to send parameters to a slot using the boost::bind routine

Since I did not find any documentation for this in the web: If you are using Wt C++ Web toolkit and ever wondered, how to send parameters to a SLOT() there is a simple solution using the boost::bind routine.

Imagine you have an button, and an event that requires one parameter then you can setup the whole scenario like this:

void MyClass::test(std::string parameter)
  cout << parameter << endl;

WPushButton *button = new WPushButton("Test", this);

button->clicked().connect(boost::bind(&MyClass::test, this, "Hello World!"));

The step which is often forgotten is to put the instance of the class right after the function pointer. (In this case “this”)

Thats it!