Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

C2664 'QMetaObject::Connection'



  • I have:

    QObject::connect(mpSpinMax, &QSpinBox::valueChanged,
        [this](int intValue) {
        int intMinValue(mpSpinMin->value());
        if ( intValue < intMinValue) {
    //Prevent value from going less than minimum
        mpSpinMax->setValue(intMinValue);
      }
    });
    QObject::connect(mpSpinMin, &QSpinBox::valueChanged,
        [this](int intValue) {
        int intMaxValue(mpSpinMax->value());
        if ( intValue > intMaxValue) {
    //Prevent value from going over maximum
        mpSpinMin->setValue(intMaxValue);
      }
    });
    

    When I compile I get:

    C2664: 'QMetaObject::Connection QObject::connect(const QObject*,const char*, const char*,Qt::ConnectionType) const': cannot convert argument 2 from 'overloaded-function' to 'const char*'
    

    This happens for each instance. Also tried:

    QObject::connect(mpSpinMax, SIGNAL(valueChanged(int)),
        [this](int intValue) {
        int intMinValue(mpSpinMin->value());
        if ( intValue < intMinValue) {
    //Prevent value from going less than minimum
        mpSpinMax->setValue(intMinValue);
      }
    });
    QObject::connect(mpSpinMin, SIGNAL(valueChanged(int)),
        [this](int intValue) {
        int intMaxValue(mpSpinMax->value());
        if ( intValue > intMaxValue) {
    //Prevent value from going over maximum
        mpSpinMin->setValue(intMaxValue);
      }
    });
    

    Same result.



  • @SPlatten , fixed, changed parameter 2 to:

    QOverload<int>::of(&QSpinBox::valueChanged)
    


  • @SPlatten , fixed, changed parameter 2 to:

    QOverload<int>::of(&QSpinBox::valueChanged)
    

Log in to reply