Results 1 to 4 of 4

Thread: Problems with QMetaObject::invokeMethod

  1. #1
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Problems with QMetaObject::invokeMethod

    I have this method:
    Qt Code:
    1. void initialize(unsigned long hwnd, int width, int height)
    To copy to clipboard, switch view to plain text mode 

    I am trying to invoke this method using QMetaObject::invokeMethod
    Qt Code:
    1. QMetaObject::invokeMethod(m_pOgreManager, "initialize", Q_ARG("usigned long", (unsigned long)renderWidget->winId()), Q_ARG("int", renderWidget->width()), Q_ARG("int", renderWidget->height()));
    To copy to clipboard, switch view to plain text mode 

    initialize is a public Member of OgreManager where m_pOgreManager is a pointer to a instance of OgreManager.

    But it does not compile:
    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'
    Last edited by AlphaWolf; 20th April 2009 at 18:27.

  2. #2
    Join Date
    Apr 2008
    Location
    Russia, Moscow
    Posts
    86
    Thanks
    2
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4

    Default Re: Problems with QMetaObject::invokeMethod

    "initialize()" - it is slot?

    Qt Code:
    1. renderWidget->winId()
    To copy to clipboard, switch view to plain text mode 
    widget may not have Id if this "Alien Widget" (ex. child inside main window).

  3. #3
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problems with QMetaObject::invokeMethod

    Q_ARG("int", renderWidget->width())

    Q_ARG takes a type not a string as the first argument

  4. #4

    Default 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 ?

Similar Threads

  1. problems creating toolbar...(do see the attachment)!
    By sumit in forum Qt Programming
    Replies: 15
    Last Post: 10th September 2008, 12:23
  2. Problems with scope and C header functions
    By waldowoc in forum Newbie
    Replies: 5
    Last Post: 5th August 2008, 12:29
  3. flicker and wierd resize problems ...
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2008, 19:00
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 16:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.