Parse error when declaring under public slot but not under public!!!
-
It would be helpful if you told us the actual error message.
-
Ok, this is the error,
C:\MyClass.h(48): Parse error at ")"
Moc'ing MyClass.h...
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): error MSB6006: "cmd.exe" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== -
After doing further analysis I've reached to some what specific issue with QT framework.
MyClass.h
@
// Refer above ...
LineNo:48 STDMETHOD(Init) ( LPTNTDRVINFO pDrvInfo); // earlier ..LineNo:48 QString intialize ( LPTNTDRVINFO pDrvInfo); // Final one.. Compilation no error, for registering obviously through cmd-line was able to register COM Dll.
@No, I can't see the initialize() function exposed? No idea what is the problem.
-
Hi,
LPTNTDRVINFO , is a structure type, declation in this form ,
@
typedef struct {// bla bla
}DRVINGO, *LPTNTDRVINFO;
@ -
STDMETHOD (Init) seems to be some kind of macro or the like. To my knowledge, moc does not use the C/C++ preprocessor prior to its own parsing. Which means that it cannot parse that line, as it is no standard "simple" method prototype.
What do you mean with "I can’t see the initialize() function exposed"?
Additionally, it may be necessary that you will have to register the LPTNTDRVINFO as a type in the Qt meta type system, see "qRegisterMetaType":http://doc.qt.nokia.com/4.7/qmetatype.html#qRegisterMetaType docs for details.
-
Hi,
Sorry for not replying soon. Due to the problem mentioned above I was engaged in writing a new plain C++ COM object(New to C++, Read a lot and implemented.) which will be a wrapper class for QT.So, its working fine.
"What do you mean with “I can’t see the initialize() function exposed”?"
Yes, Your correct due to lack of experience in C++, I'm not familiar with the terms used in C++, will be improved in coming days.What I meant is in the generated *idl file , its mentioned as un-supported type.
@
Line 45: QString getdata();
LineNo:48 QString intialize ( LPTNTDRVINFO pDrvInfo); // LPTNTDRVINFO, un-supported type.
@Due to this , the class which calls my COM object can only see getdata(), means unable to call initialize(). So, *qRegisterMetaType * will solve this requirement ? Need your thoughts!!!
-
Sorry, I never got my hands dirty with COM objects and IDL files, I can only speak of Qt design principles in general. So, to use custom data types in signals/slots you need to call qRegisterMetatype. I don't know whether that works - I suggest just trying it out.
And regardig that STDMETHOD problem, from a quick search on google, I'd say it's a macro - and moc seems not to support this notation.
As a workaround, you might just add your STDMETHOD in the public section, and add an additional standard public slot that calls the other method as implementation (or the other way round, that's up to you).
-
Hi,
As a side note: STDMETHOD declares a method as:
@
HRESULT __stdcall foo();
@I'm pretty sure, moc can't understand these macros, especially, as the C pre proc is not running before moc is run.
The Qt ActiveX stuff exports signals and slots out of the meta object description. All data types that can be put to a QVariant can be used as parameters. If you define custom types, you must use qRegisterMetaType to add the type to the meta info. Then it should be possible to use it.
By the way, in your OP, you had Init 2 times defined. one time as COM method and one time as slot.
-
No, I just wanted to show that, declaring under slots gave me error(as you said , moc runs ) and the same declaring under public donot throw error.
I'm trying out with Qvariant, since I've no control over the 3rd class which declares the virtual methods as mentioned above.
-
The point is, if it is declared under slots, it IS parsed by moc, which results in the error. MOC does some validation and the produces a build error.