I have a C++ class defined with a method which has a sol (pointer to member method) as argument:
MyClass : public QDialog, private Ui::MyClassBase
{
Q_OBJECT
public:
MyClass( QWidget *parent = nullptr );
void connectValueChanged( const QList<QWidget *> &widgets, void ( MyClass::*slot )() );
}
and
void MyClass::connectValueChanged( const QList<QWidget *> &widgets, void ( MyClass::*slot )() )
{
Q_FOREACH ( QWidget *widget, widgets )
{
connect( w, &QWidget::signal, this, slot );
}
}
The connectValueChanged
cannot be used as defined in the SIP file, I get a syntax error.
I also tried to use const char *slot
without success:
In the SIP file
void MyClass::connectValueChanged( const QList<QWidget *> &widgets, const char *slot);
I get an error (no matching function for call to ‘MyClass::connectValueChanged
) as I suppose I need some MethodCode
to achieve this.
Maybe some hints:
- existing Qt method but using the old signal/slot connection.
- SIP extension API either.
static QMetaObject::fromSignal
(returning aQMetaObject
) header and definition
What shall I do to define a method with a slot as argument in SIP ?
I think this requires some MethodCode
I am not capable to write at the moment.
I would like to use Qt5 new signal/slot connection (avoid using const char *slot
in the cpp method, put possibly in the python method with some MethodCode
)