XML GUI question

Simon Hausmann hausmann at kde.org
Mon Oct 28 16:41:08 GMT 2002

On Mon, Oct 28, 2002 at 05:22:54PM +0100, Michael Goffioul wrote:
> > I'm not exactly sure I understand the problem, but if you want to
> > make kghostview's GUI visibile in your dialog then the following
> > code snipped should probably work:
> > 
> > KXMLGUIBuilder *builder = new KXMLGUIBuilder( dialog );
> > KXMLGUIFactory *guiFactory = new KXMLGUIFactory( builder );
> > guiFactory->addClient( ghostviewPart );
> > 
> > ...
> > 
> > (and possibly later in your destructor)
> > guiFactory->removeClient( ghostviewPart );
> > delete guiFactory;
> > delete builder;
> > 
> > Is that what you mean?
> I'm not sure. What's the effect of that code? How do you create the
> toolbar? Maybe it's automatically done in addClient. But in the
> end, there's no KMainWindow, so the code of KToolBar::loadState()
> (which is used to actually create the toolbar) will return
> immediately because of the test at the beginning. Am I wrong?

You're right :) . But that shouldn't prevent the toolbar from
appearing (under the condition that it is created before the dialog
is shown) . loadState() doesn't create the toolbar after all, it
just applies a couple of options (and calls show()/hide() , which
however shouldn't be necessary in your code given the above
mentioned constraint) .

But I guess you want to have full control of the toolbar creation,
to place it wherever appropriate in your dialog. In that case just
inherit from KXMLGUIBuilder, re-implement the createContainer method
and create your toolbar if element.tagName().lower() is "toolbar" .


More information about the kde-core-devel mailing list