Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.7.2
-
None
Description
QML_FOREIGN_NAMESPACE is unable to find classes referenced via an alias, producing warning: com::AliasName is declared as foreign type, but cannot be found.
Alias creation can be done with either the "using" syntax or the "typedef" syntax. Both will result in the same warning.
The following example can be copy-pasted into a header to re-produce the issue:
#ifndef CLASSNAME_H
#define CLASSNAME_H
#include <QObject>
#include <QQuickItem>
namespace com {
namespace A {
class ClassName
{
Q_GADGET
QML_ELEMENT
};
} // namespace A
// Class B comes from namespace A
using AliasName = com::A::ClassName;
//// Alternatively we could use typedef and it would produce the same outcome
// typedef com::A::ClassName }}{{{}AliasName;
namespace B {
Q_NAMESPACE
QML_FOREIGN_NAMESPACE(com::AliasName)
QML_NAMED_ELEMENT(ClassName)
} // namespace B
} // namespace com
#endif // CLASSNAME_H