v0.8-dev - Passing custom parameters

Started by roccio, 15 May 2018, 13:57:51


Hello, I have not understand how to correctly pass custom parameters is signal functions.
In my case I have a class member function that has 1 parameter as input

void PanelClient::windowChooseKey(const std::string& textbox)

I connect this function to a button press

button->connect("pressed", &PanelClient::windowChooseKey, "txtWindowShowHideKey", this);

but I am not able to compile.

What's the correct way of doing this?


The 'this' parameter is always the first one of a member function, so the line should be
Code (cpp) Select
button->connect("pressed", &PanelClient::windowChooseKey, this, "txtWindowShowHideKey");


Still have the same error (Visual C++ 2015 reports error C2075).

class PanelClient
    void windowChooseKey(const std::string& textbox)
        std::cout << "Here I am" << std::endl;

later in code...

button->connect("pressed", &PanelClient::windowChooseKey, this, "txtWindowShowKey" );

When compiling error C2075


The 'this' parameter has to be a pointer to the class instance (the value that 'this' would have when using 'this' inside the callback function itself). So you have to pass something else when the connect call is not being called from inside the PanelClient class.
Code (cpp) Select
PanelClient client;
button->connect("pressed", &PanelClient::windowChooseKey, &client, "txtWindowShowKey" );

Edit: If that isn't the problem then could you show the build output? I just googled C2075 and it seems like it has nothing to do with this line itself. Are you using VS2015 update 2 or higher?