[Interest] QObject::connect

Thiago Macieira thiago.macieira at intel.com
Thu Jun 26 17:50:08 CEST 2014


Em qui 26 jun 2014, às 18:43:54, igor.mironchik at gmail.com escreveu:
> Hi guys,
> 
> I have one simple question:
> 
> Is it possible to make connection with new syntax (using QMetaMethod) if
> object has two or more signals with the same name but with different
> argument’s type?

If I ignore the parentheses above, the answer is yes.

If I include the parentheses, I have to ask: what does QMetaMethod have to do 
with the new connection syntax? I'm not sure you understand what you're 
asking.

> For example, QComboBox::currentIndexChanged... There are two signals with
> int and QString...
> 
> Or for such connection user *must* use old syntax?

You need to cast the pointer-to-member-function to the type that you want. You 
do that via static_cast or by assigning it to a PMF variable.

	void (QComboBox:: *signal)(int) = &QComboBox::currentIndexChanged;
	connect(comboBox, signal, this, &MyClass::doSomething);

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list