C++ Qt’;是否定义了s PointerToMemberFunction?

C++ Qt’;是否定义了s PointerToMemberFunction?,c++,qt,qobject,qsharedpointer,C++,Qt,Qobject,Qsharedpointer,在年,我能够适应QObject方法 QMetaObject::Connection QObject::connect(const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoConnection) 转换为接受QSharedPointer而不是QObject*作为其第一个

在年,我能够适应
QObject
方法

QMetaObject::Connection
QObject::connect(const QObject * sender,
    const char * signal,
    const QObject * receiver,
    const char * method,
    Qt::ConnectionType type = Qt::AutoConnection)
转换为接受
QSharedPointer
而不是
QObject*
作为其第一个参数的变量:

template<class T> QMetaObject::Connection
connect_from_pointer(const QSharedPointer<T> &sender,
    const char *signal,
    const QObject *receiver,
    const char *method,
    Qt::ConnectionType type = Qt::AutoConnection)
但是我不知道什么是
指针ToMemberFunction
或者它是在哪里定义的!这种类型是什么?

它只是文档中的“糖”,您可以在
qobject.h
中找到真正的定义(Qt源代码):

静态QMetaObject::连接连接(const QObject*发送方,const char*信号,
常量QObject*接收器,常量字符*成员,Qt::ConnectionType=Qt::自动连接);
静态QMetaObject::连接连接(const QObject*发送方,const QMetaMethod&signal,
常数QObject*接收器,常数QMetaMethod和method,
Qt::ConnectionType类型=Qt::自动连接);
内联QMetaObject::连接连接(常量QObject*发送方,常量char*信号,
常量char*成员,Qt::ConnectionType=Qt::AutoConnection)常量;
#ifdef Q_QDOC
静态QMetaObject::Connection connect(const QObject*发送方,pointertomberfunction信号,const QObject*接收方,pointertomberfunction方法,Qt::ConnectionType=Qt::AutoConnection);
静态QMetaObject::连接连接(const QObject*sender,PointerToMemberFunction信号,Functor Functor);
静态QMetaObject::Connection connect(const QObject*发送方,PointerToMemberFunction信号,const QObject*上下文,Functor Functor,Qt::ConnectionType=Qt::AutoConnection);
#否则
//将信号连接到指向qobject成员函数的指针
模板
静态内联QMetaObject::连接连接(const typename QtPrivate::FunctionPointer::Object*sender,Func1信号,
常量typename QtPrivate::FunctionPointer::Object*接收器,Func2插槽,
Qt::ConnectionType类型=Qt::自动连接)
{
typedef QtPrivate::FunctionPointer SignalType;
typedef QtPrivate::FunctionPointer SlotType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value,
“类中没有带信号的Q_对象”);
//如果参数不匹配,则编译错误。
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount)>=int(SlotType::ArgumentCount),
“插槽需要的参数比信号提供的参数多。”);
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments::value),
“信号和插槽参数不兼容。”);
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value),
“插槽的返回类型和信号的返回类型不兼容。”);
常量int*types=0;
if(类型==Qt::QueuedConnection | |类型==Qt::BlockingQueuedConnection)
types=QtPrivate::ConnectionTypes::types();
返回连接MPL(发送方、重新解释和信号),
接收器,重新解释铸件和槽,
新的QtPrivate::QSlotObject(插槽),
类型、类型和信号类型::对象::staticMetaObject);
}
QMetaObject::Connection
QObject::connect(const QObject * sender,
    PointerToMemberFunction signal,
    const QObject * receiver,
    PointerToMemberFunction method,
    Qt::ConnectionType type = Qt::AutoConnection)
    static QMetaObject::Connection connect(const QObject *sender, const char *signal,
                        const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);

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

    inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
                        const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;

#ifdef Q_QDOC
    static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
    static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
    static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
#else
    //Connect a signal to a pointer to qobject member function
    template <typename Func1, typename Func2>
    static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
                                     const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot,
                                     Qt::ConnectionType type = Qt::AutoConnection)
    {
        typedef QtPrivate::FunctionPointer<Func1> SignalType;
        typedef QtPrivate::FunctionPointer<Func2> SlotType;

        Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
                          "No Q_OBJECT in the class with the signal");

        //compilation error if the arguments does not match.
        Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
                          "The slot requires more arguments than the signal provides.");
        Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
                          "Signal and slot arguments are not compatible.");
        Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
                          "Return type of the slot is not compatible with the return type of the signal.");

        const int *types = 0;
        if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
            types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();

        return connectImpl(sender, reinterpret_cast<void **>(&signal),
                           receiver, reinterpret_cast<void **>(&slot),
                           new QtPrivate::QSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
                                           typename SignalType::ReturnType>(slot),
                            type, types, &SignalType::Object::staticMetaObject);
    }