Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-36119

QObject::connect compile error with pointers to members

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.3.0
    • 5.2.0
    • Core: Object Model
    • None
    • Visual Studio 2012, Qt 5.2, Qt addin 1.2

    Description

      QMetaObject::Connection QObject::connect(const QObject * sender, PointerToMemberFunction signal, const QObject * receiver, PointerToMemberFunction method, Qt::ConnectionType type) method fails (in compile time), when trying to connect Signal and Slot with QMessageLogContext as argument.

      Sender.h:

      class Sender : public QObject
      {
      	Q_OBJECT
      signals:
      	void test3( const QMessageLogContext& context );
      //...
      };
      

      Receiver.h:

      class Receiver : public QObject
      {
      	Q_OBJECT
      public slots:
      	void test3( const QMessageLogContext& context );
      // ...
      };
      

      Main.cpp:

      QObject::connect( &snd, &Sender::test3, &rcv, &Receiver::test3 ); // Compile error
      

      Using Qt4-style connect working ok.
      There are sample project in attached file, that demonstrate problem.

      Error text:

      1>C:\Qt\Qt5.2.0\5.2.0\msvc2012\include\QtCore/qobjectdefs_impl.h(573): error C2248: 'QMessageLogContext::QMessageLogContext' : cannot access private member declared in class 'QMessageLogContext'
      1>          C:\Qt\Qt5.2.0\5.2.0\msvc2012\include\QtCore/qlogging.h(66) : see declaration of 'QMessageLogContext::QMessageLogContext'
      1>          C:\Qt\Qt5.2.0\5.2.0\msvc2012\include\QtCore/qlogging.h(65) : see declaration of 'QMessageLogContext'
      1>          C:\Qt\Qt5.2.0\5.2.0\msvc2012\include\QtCore/qobjectdefs_impl.h(588) : see reference to class template instantiation 'QtPrivate::AreArgumentsCompatible<A1,A2>' being compiled
      1>          with
      1>          [
      1>              A1=QMessageLogContext,
      1>              A2=QMessageLogContext
      1>          ]
      1>          c:\qt\qt5.2.0\5.2.0\msvc2012\include\qtcore\qobject.h(228) : see reference to class template instantiation 'QtPrivate::CheckCompatibleArguments<List1,List2>' being compiled
      1>          with
      1>          [
      1>              List1=QtPrivate::List<const QMessageLogContext &,void>,
      1>              List2=QtPrivate::List<const QMessageLogContext &,void>
      1>          ]
      1>          main.cpp(15) : see reference to function template instantiation 'QMetaObject::Connection QObject::connect<void(__thiscall Sender::* )(const QMessageLogContext &),void(__thiscall Receiver::* )(const QMessageLogContext &)>(const Sender *,Func1,const Receiver *,Func2,Qt::ConnectionType)' being compiled
      1>          with
      1>          [
      1>              Func1=void (__thiscall Sender::* )(const QMessageLogContext &),
      1>              Func2=void (__thiscall Receiver::* )(const QMessageLogContext &)
      1>          ]
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ogoffart Olivier Goffart (Woboq GmbH)
            sazonov Dmitry Sazonov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes