[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Problem with KActions appering in KActionList menu
From:       Robin Perkins <robin.perkins () internode ! on ! net>
Date:       2004-05-08 15:29:48
Message-ID: DD4A21FE-A102-11D8-BF58-003065A9AA70 () internode ! on ! net
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I'm having a few problems with getting KActionList to create a dynamic 
menu. In the code below - my menu "&Zeroconf" is created and has only 
one KAction "&Debug". When "&Debug" is selected it prints a dialog 
telling me that there are 5 items in openWithAction however these do 
not appear in the "&Zeroconf" menu. Any ideas what is going wrong?

Thanks

Rob

 From my .cpp file:

PluginMdnsBrowser::PluginMdnsBrowser( QObject* parent, const char* name 
)
    : Plugin( parent, name )
{
    // Instantiate all of your actions here.  These will appear in
    // Konqueror's menu and toolbars.
    (void) new KAction (i18n ("&Debug"), 0, this, SLOT(slotopenURL() ),
                        actionCollection(), "debugmessage" );
                    
   unplugActionList("zeroconf_items");
   openWithActions.clear();
    QString actionname;
    for (uint i = 0; i < 5; i++ ) {
     actionname = "somethingaction No %1";
     actionname = actionname.arg(i);

    KAction *action = new KAction (i18n ("&Something"),0, this, SLOT(
             slotopenURL() ), actionCollection(), actionname );
   
    openWithActions.append(action);
    }
   plugActionList("zeroconf_items", openWithActions);

}

void PluginMdnsBrowser::slotopenURL()
{
   QString message = "openWithActions has %1 item(s)";
   message = message.arg(openWithActions.count());
   KMessageBox::information(NULL, message, i18n("Debug 
Message"),QString::null, 1);
}

 From my .rc file:

<!DOCTYPE kpartgui>
<kpartplugin name="mdnsbrowser" library="libmdnsbrowserplugin"
version="1">
<MenuBar>
  <Menu name="zeroconf">
   <Text>&amp;Zeroconf</Text>
   <Action name="debugmessage">
   <ActionList name="zeroconf_items">
  </Menu>
</MenuBar>
</kpartplugin> 

<fontfamily><param>Courier</param>I'm having a few problems with
getting KActionList to create a dynamic menu. In the code below - my
menu "&Zeroconf" is created and has only one KAction "&Debug". When
"&Debug" is selected it prints a dialog telling me that there are 5
items in openWithAction however these do not appear in the "&Zeroconf"
menu. Any ideas what is going wrong?


Thanks


Rob


From my .cpp file: 


PluginMdnsBrowser::PluginMdnsBrowser( QObject* parent, const char*
name ) 

    : Plugin( parent, name ) 

{ 

    // Instantiate all of your actions here.  These will appear in 

    // Konqueror's menu and toolbars. 

    (void) new KAction (i18n ("&Debug"), 0, this, SLOT(slotopenURL()
), 

                        actionCollection(), "debugmessage" ); 

                     

   unplugActionList("zeroconf_items"); 

   openWithActions.clear(); 

   QString actionname;

   for (uint i = 0; i << 5; i++ ) {

    actionname = "somethingaction No %1";

    actionname = actionname.arg(i);


    KAction *action = new KAction (i18n ("&Something"),0, this, SLOT(

            slotopenURL() ), actionCollection(), actionname ); 

    

    openWithActions.append(action); 

   }

   plugActionList("zeroconf_items", openWithActions); 


} 


void PluginMdnsBrowser::slotopenURL() 

{ 

   QString message = "openWithActions has %1 item(s)"; 

   message = message.arg(openWithActions.count()); 

   KMessageBox::information(NULL, message, i18n("Debug
Message"),QString::null, 1); 

} 


From my .rc file: 


<<!DOCTYPE kpartgui> 

<<kpartplugin name="mdnsbrowser" library="libmdnsbrowserplugin"

version="1"> 

<<MenuBar> 

 <<Menu name="zeroconf"> 

   <<Text>&amp;Zeroconf<</Text> 

   <<Action name="debugmessage"> 

   <<ActionList name="zeroconf_items"> 

 <</Menu> 

<</MenuBar> 

<</kpartplugin><color><param>3333,3333,3333</param> </color></fontfamily>

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic