KToggleToolBarAction?

John Firebaugh jfirebaugh at kde.org
Thu Apr 4 02:21:22 BST 2002


On Wednesday 03 April 2002 11:33, Ellis Whitehead wrote:
> On Wednesday 03 April 2002 09:05, Guillaume Laurent wrote:
> > On Wednesday 03 April 2002 16:10, Ellis Whitehead wrote:
> > > On Wednesday 03 April 2002 01:05, John Firebaugh wrote:
> > > > How do I get a pointer to the main window from plug()? Follow parents
> > > > until I find one that inherits("KMainWindow")?
> > >
> > > Exactly.
> >
> > Can't you use QWidget::topLevelWidget() ?
>
> I don't know if this has changed for Qt 3.x, but in 2.x topLevelWidget()
> didn't always go back far enough.  I'm not basing this on personal
> experience, though, and I don't know where it would get stuck.  KDialog?
> Anyhow, there's a note about it in kaction.cpp, and the KAction API used to
> have a findMainWindow() method to deal with the problem.

This findMainWindow() method would be handy, as I've basically copied the code 
from plugMainWindowAccel() that finds the KMainWindow parent. Why was it 
removed?

I have another problem: I end up with duplicate toolbars. Sequence of events:

1. KToggleToolBarAction is created before the GUI is built.
2. When plugged, it calls KMainWindow::toolBar("myToolBar"). Probably, the 
toolbar which it wants hasn't yet been created by the GUI builder, so 
KMainWindow creates a new one.
3. KXMLGUIBuilder is asked to create myToolBar, and it creates another new 
one.

Thus we end up with two toolbars named "myToolBar". The KToggleToolBarAction 
knows about the first one, while actions show up in the second one.

It seems to me that KXMLGUIBuilder should ask the main window for the toolbar, 
not create it itself. Anyone familiar with this code know for sure?

later,
John




More information about the kde-core-devel mailing list