Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Run-time error : QMetaType::registerType: Binary compatibility break -- Size mismatch for type ...

    General and Desktop
    2
    3
    612
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      ddze last edited by

      I have a run-time crash due to a qRegisterMetaType();

      1. So a class to be registered is declared with the Q_DECLARE_METATYPE.
      class IBase {
      public:
          IBase();                      /** default constructor*/
          IBase(const IBase & a);       /** copy constructor */
          ~IBase(){}                    /** destructor */
      };
      Q_DECLARE_METATYPE(IBase)
      
      1. the constructor of the class that uses the IBase calls the qRegisterMetaType() and than crashes.
      IBaseMimeData::IBaseMimeData(const IBase *mod){
          refModule = mod;
          qRegisterMetaType<IBase*>("IBase");   // <<  RUN-TIME CRASH
          supportedFormats <<DRAG_AND_DROP_MIME_NAME;
      }
      
      

      How to fix this problem.? I do not have any other Qt libraries but the Version 5.50 / and the compiler Mingw 492.

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @ddze last edited by

        @ddze
        Hello,
        You're doing it wrong.

        IBaseMimeData::IBaseMimeData(const IBase * mod)
        {
            // ...
            qRegisterMetaType<IBase>();   //< IBase is declared, not IBase *. Don't pass a string argument to the function!
            // ...
        }
        

        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 1
        • D
          ddze last edited by ddze

          @kshegunov , you are a legend. Thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post