Project

General

Profile

How to make Signal Slot that takes argument?

Added by Fahmi Noorain over 12 years ago

Hi,

I'm am beginner programmer. Before this I'm using Qt for GUI development in OpenSUSE and familiar with signal slot mechanism. But 'm a little bit confuse with this mechanism in Wt.

I've already read the documentation. But I'm still not get how to pass arguments between a signal and slot. In Qt you can use syntax like this:

connect(&a, SIGNAL (valueChanged(int)), &b, SLOT (setValue(int)));

But how it is done in Wt?


Replies (5)

RE: How to make Signal Slot that takes argument? - Added by Fahmi Noorain over 12 years ago

*Sorry

connect(&a, SIGNAL(valueChanged(int)), &b, SLOT(setValue(int)));

RE: How to make Signal Slot that takes argument? - Added by Mohammed Rashad over 12 years ago

Hey,

you can use boost::bind. or simply like this

QPushButton::connect(this,&MyClass::myButtonClicked)

the parameters are not specified explicitly

its passed automatically

http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WTreeView.html#a8d014f2cd6637f5f842d7fe2fff00418

collapsed singal passes a parameter called WModelIndex.

Here is how you connect a collapsed signal of MyTreeView which of type WTreeView

MyTreeView.collapsed().connect(this,&MyClass::myCollapsed);

the slot will look like this

void myCollapsed(WModelIndex &index)

{

//your collapsed code

}

RE: How to make Signal Slot that takes argument? - Added by Fahmi Noorain over 12 years ago

Thank you..syukran for the answer. But that's not what exactly I'm asking about. I know that some Wt signal pass the arguments like internalPathChanged(). But how to make our own signal with arguments?

RE: How to make Signal Slot that takes argument? - Added by Wim Dumon over 12 years ago

Hello Fahmi,

that would be Signal<std::string> mySignal. But feel free to use boost.signal directly, since that's what Wt's signals are based on.

BR,

Wim.

RE: How to make Signal Slot that takes argument? - Added by Fahmi Noorain over 12 years ago

Thanks for both replies. After some reading, I finally understand how Wt signal works. My problem solved.

Ps..not sure how to change the thread title.

    (1-5/5)