[Interest] QObject::connect

igor.mironchik at gmail.com igor.mironchik at gmail.com
Thu Jun 26 20:04:11 CEST 2014


Thanks guys for your answers. I found what I was seeking.

And what about parentheses and QMetaMethod that I wanted to concretize what 
I mean under new syntax of connection.

As new connect method is:

QMetaObject::Connection QObject::connect(const QObject * sender, const 
QMetaMethod & signal, const QObject * receiver, const QMetaMethod & method, 
Qt::ConnectionType type = Qt::AutoConnection)

so I have written in parantheses: (using QMetaMethod).

Thanks again.

-----Original Message----- 
From: Thiago Macieira
Sent: Thursday, June 26, 2014 5:50 PM
To: interest at qt-project.org
Subject: Re: [Interest] QObject::connect

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

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest 




More information about the Interest mailing list