1. Qt
  2. QTBUG-41004

New connect syntax fails with msvc in special corner cases


    • Type: Bug Bug
    • Status: Closed
    • Priority: P2: Important P2: Important
    • Resolution: Out of scope
    • Affects Version/s: 5.4.0
    • Fix Version/s: None
    • Component/s: Core: Object Model
    • Labels:
    • Environment:

      Windows, msvc


      Qt Creator stumbled over an issue where a connect with the new member fuction pointer based method compiled nicely but then failed at runtime with a

      QObject::connect: signal not found in Foo

      It is really much of a corner in this case which in addition seems to happen only with msvc. Not sure if this can be considered a compiler bug or a bug in Qt. Anyway I post this here for the records.

      Scenario: A class has a signal which overrides a virtual member function of its base class. When trying to connect to the signal of the derived class from outside the library (.dll) where the two classes "live", apparently a wrong method pointer is created. The result is the above message at runtime.

      Code in the library:

      class LIBSHARED_EXPORT A : public QObject
          virtual void foo(int) {}
      class LIBSHARED_EXPORT B : public A
          void foo(int);
          void bar();

      Code outside the library:

          B b;
          QObject::connect(&b, &B::foo, &a, &QCoreApplication::quit); // causes runtime "QObject::connect: signal not found in B"
          QObject::connect(&b, &B::bar, &a, &QCoreApplication::quit); // succeeds

      See the attached msvcissue.zip for a working demo.

      1. msvcissue.zip
        2 kB
        Alessandro Portale

        Issue Links

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


          No work has yet been logged on this issue.


            • Assignee:
              Thiago Macieira
              Alessandro Portale
            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created:

                Gerrit Reviews

                There are no open Gerrit changes