Problems with QMetaObject::invokeMethod
I have this method:
Code:
void initialize(unsigned long hwnd, int width, int height)
I am trying to invoke this method using QMetaObject::invokeMethod
Code:
QMetaObject::invokeMethod(m_pOgreManager,
"initialize", Q_ARG
("usigned long",
(unsigned long)renderWidget
->winId
()), Q_ARG
("int", renderWidget
->width
()), Q_ARG
("int", renderWidget
->height
()));
initialize is a public Member of OgreManager where m_pOgreManager is a pointer to a instance of OgreManager.
But it does not compile:
Quote:
1>uglyviewer.cpp
1>.\src\uglyviewer.cpp(34) : error C2974: "QReturnArgument": Ungültiges template-Argument für "T", Typ erwartet.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(269): Siehe Deklaration von 'QReturnArgument'
1>.\src\uglyviewer.cpp(34) : error C2955: "QReturnArgument": Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(269): Siehe Deklaration von 'QReturnArgument'
1>.\src\uglyviewer.cpp(34) : error C2974: "QArgument": Ungültiges template-Argument für "T", Typ erwartet.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
1>.\src\uglyviewer.cpp(34) : error C2955: "QArgument": Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
1>.\src\uglyviewer.cpp(34) : error C2974: "QArgument": Ungültiges template-Argument für "T", Typ erwartet.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
1>.\src\uglyviewer.cpp(34) : error C2955: "QArgument": Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
1>.\src\uglyviewer.cpp(34) : error C2974: "QArgument": Ungültiges template-Argument für "T", Typ erwartet.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
1>.\src\uglyviewer.cpp(34) : error C2955: "QArgument": Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.
1> c:\qt\4.5.0\include\qtcore\../../src/corelib/kernel/qobjectdefs.h(259): Siehe Deklaration von 'QArgument'
Re: Problems with QMetaObject::invokeMethod
"initialize()" - it is slot?
Code:
renderWidget->winId()
widget may not have Id if this "Alien Widget" (ex. child inside main window).
Re: Problems with QMetaObject::invokeMethod
Q_ARG("int", renderWidget->width())
Q_ARG takes a type not a string as the first argument:)
Re: Problems with QMetaObject::invokeMethod
HI ,
Facing an issue for passing a pointer as QARG in invokeMethod :
I am calling the api void CAppManager::launchUrl(const int f_iXcoord,const int f_iYcoord,const int f_iHeight, const int f_iWidth,const QString f_cobjUrl,unsigned long *f_ulRenHandle,bool bSetupURL) as
QMetaObject::invokeMethod(this,"launchUrl",Qt::Que uedConnection,
Q_ARG(int,0),Q_ARG(int,0),Q_ARG(int,480),Q_ARG(int ,800),Q_ARG(QString,sSetUpURL),Q_ARG(unsigned long*,handle),Q_ARG(bool,true));
The issue seems to be with ARG f_ulRenHandle . As when the function had this argument only as pass by value and in InvokeMethod I had passed just Q_ARG(unsigned long,handle) instead of Q_ARG(unsigned long*,handle).It worked.
handle here has to be pointer or refrence as its getting modified in launchURL API .Here I am using pointer as we can't use Refrences with Q_ARG.Here invoke method is always returning 0.
I am initializing/declaring handle as follows :
unsigned long dummyHandle=0;
unsigned long * handle = &dummyHandle;
Please let me know what measure should i take to solve this issue ?