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

QMetaType id of custom QObject subclass unknown prior to fetching id from QVariant

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5.0, 6.5.1, 6.6.0
    • 6.5.0 RC
    • Core: Other
    • None
    • All
    • 8570e86ff (dev), 22943b3a3 (6.5.0), 298657409 (6.5)

    Description

      When having a custom QObject subclass the typeid is not known to QMetaType::type() in Qt 6.5.0 RC anymore unless something has fetched the typeid from a wrapped QVariant before.

      The following code reproduces this (complete code is attached)

          CustomQObject customObject; // simple subclass from QObject, including a Q_OBJECT macro
          const QVariant customVariant = QVariant::fromValue(&customObject);
          assert(QMetaType::type("CustomQObject*") != 0); // fails on 6.5.0 RC, works on 6.4.0 and earlier
          assert(customVariant.userType() != 0);
          assert(QMetaType::type("CustomQObject*") != 0);
      

      This is a problem for Squish when trying to find out if a referenced QVariant can be converted into such a custom type because Squish first asks the QMetaType registry about the custom type before extracting it from a QVariant. All of this has to be done using strings and integer type ids in Squish since it does not and cannot directly access the C++ types from the application it is testing.

      Attachments

        1. metatypeidtest.cpp
          0.5 kB
        2. metatypeidtest.h
          0.2 kB
        3. metatypeidtest.pro
          0.1 kB
        For Gerrit Dashboard: QTBUG-112205
        # Subject Branch Project Status CR V

        Activity

          People

            thiago Thiago Macieira
            stefgehn Stefan Gehn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes