[Kommander-devel] Re: Accessing a QAction in a Kommander Plugin

Eric Laffoon eric at kdewebdev.org
Sun Feb 24 16:13:16 EST 2008


On Sunday 24 February 2008 5:12:35 am Kevin Krammer wrote:
> bool QtActionProxy::actionIsOn(const QString& action)
> {
>   QWidget* mainWindow = kapp->mainWidget();
>   if (mainWindow == 0) return false; // no main widget
>   QAction* childAction =
> dynamic_cast<QAction*>(mainWindow->child(action.utf8 (), "QAction"));
>   if (childAction == 0) return false;
>
>   return childAction->isOn();
> }

I had to add #include <kapplication.h> after which I get ironically exactly 
the same compile error I have in the past...

../../src/qtactionproxy.cpp: In member function 'bool 
QtActionProxy::actionIsOn(const QString&)':
../../src/qtactionproxy.cpp:160: error: expected unqualified-id before numeric 
constant
../../src/qtactionproxy.cpp:160: error: expected ';' before numeric constant
../../src/qtactionproxy.cpp:160: error: '1' cannot be used as a function

This is what I just don't understand. childAction should be a QAction* so what 
does the expected unqualified-id mean? Where does the '1' come from and how 
is it being used as a function? 

I can read and understand your code. Am I missing an include? Am I creating 
conflicts with my includes?

#include <qobject.h>
#include <qwidget.h>
#include "qtactionproxy.h"
#include <kapplication.h>

#include <kommanderplugin.h>
#include <specials.h>

#include <kglobal.h>
#include <kiconloader.h>
#include <klocale.h>
#include <qlabel.h>
#include <qaction.h>
#include <qcstring.h>

I probably have extras I don't need from copying other plugins.

Thanks again for your help. It's frustrating to keep coming back to the same 
cryptic compile error and thinking I missed something. As I mentioned 
previously in this thread the plugin is in SVN if looking at the code in situ 
helps. I have not altered the known broken second function as I figure there 
is no point until I get through the first without compile errors.

-- 
Eric Laffoon
Project Lead - kdewebdev module


More information about the Kommander-devel mailing list