Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have some code that looks something like this:

class MyClass : public QObject
{
    Q_OBJECT

signals:
    void SetValue(float value);

public slots:
    void OnSetValue(float value, bool fromDatabase = false);
}

Connect(this, SIGNAL(SetValue(float)), this, SLOT(OnSetValue(float)));

This works fine but I want to take advantage of Qt5's new signal/slot syntax (and remove the macros). If I change the connect() to this:

connect(this, &MyClass::SetValue, this, &MyClass::OnSetValue);

I get (in Visual Studio 2013):

error C2338: The slot requires more arguments than the signal provides

I could create an intermediary function that calls OnSetValue() and allows the default parameters to be set but that seems like a waste of code. What's a better way of solving this?

share|improve this question
    
According to Qt wiki, it's not possible with member function pointers: wiki.qt.io/New_Signal_Slot_Syntax#cons. – sim642 4 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.