[Interest] Sharing enums between ActiveQt classes
S R
sr.pointe at gmail.com
Mon Apr 21 17:13:36 CEST 2014
Hi. I am having trouble using the same enum in multiple classes with
ActiveQt.
1. If I define the enum (TestEnum) in class QClass1, properties and slots
in class QClass1 that use TestEnum work well.
a) I define the enum TestEnum publicly in class QA.
b ) Then, I include Q_ENUMS(TestEnum) to register the enum to the
meta-object system.
c) I include the QAXCLASS(QClass1) macro to make class QClass1 available
in the created DLL.
d) If I look at the generated idl, I see the enumeration. Properties and
public slots are available as COM properties and methods. Everything seems
good.
2. However, I am unable to use the enum defined in class QClass1 in another
class QClass2.
a) I reference TestEnum in properties and public slots like
QClass1::TestEnum.
b) Everything compiles without error. MOC seems happy with the syntax.
c) However, properties and methods in QClass2 that use the QClass1 enum are
excluded from the COM object. If I examine the generated IDL file, I see
that the generated slots and properties are commented out. For example, I
see "/****** Property is of unsupported datatype" before properties that
use the enum.
3. I have tried as many variations as I can think of. For example...
a) If I move the enum from QClass2 to QClass1, then I see the problem in
reverse. The properties and methods of QClass2 seem fine but QClass1 now
shows "unsupported datatype". This seems to confirm that I have not made
some trivial error in QClass2.
b) I have sprinkled lots of variations of Q_DECLARE_METATYPE and
qRegisterMetaType around but nothing seems to help. Maybe I am doing this
incorrectly or in the wrong place.
c) I rearranged the order of declarations, QAXCLASS macros, etc. Nothing
seemed to help.
d) I spent some time looking at the qaxserver.cpp source code but without
learning anything. From that, I don't see how one class could know about
another enums from another class.
I have simplified my example, but my ideal would be to have the enums
globally available to every class in my DLL. I am artificially associating
their definition with a single class; conceptually, they would be global.
Is what I am trying to do possible? What am I missing? This does not seem
like an unusual situation.
Thanks,
Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140421/d599fb6d/attachment.html>
More information about the Interest
mailing list