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

List:       kde-devel
Subject:    Re: kpart layout manager
From:       David Faure <david () mandrakesoft ! com>
Date:       2002-05-31 8:14:26
[Download RAW message or body]

On Friday 31 May 2002 10:10, Shaun Jackman wrote:
> The main widget of my kpart needs a QGridLayout to lay itself out. I 
> can't seem to figure out how to get my kpart widget's layout manager 
> to play nicely with the layout manager of the main app window. 
> Unfortunately, the QGridLayout() constructor is crashing. I know the 
> parent has a layout, because if I construt the QGridLayout with the 
> parent widget instead of the parent layout, it complains parent 
> already has a layout.
> 
> I've attached a small code snippet that should have the important 
> stuff. If someone could help me out here I'd greatly appreciate it. 
> I'm stumped.
> 
> Thanks,
> Shaun
> 
> Editor::Editor( QWidget* parent, const char* name)
> 		: QWidget( parent, name)
> {
> 	QGridLayout* grid = new QGridLayout( parent->layout());
Nope, don't do that ;)
Use "this" here.

> 	grid->setColStretch(1, 1);
> 	grid->setColStretch(2, 1);
> 	grid->setSpacing(4);
> 	grid->setMargin(4);
> 	
> 	mFile = new QLabel( "filename", this);
> 	grid->addMultiCellWidget(mFile, 0, 0, 0, 3);
> 	// clip more widgets follow
> }
> 
> Kid3Part::Kid3Part( QWidget* parent, const char* name)
>     : KParts::ReadWritePart( parent, name)
> {
>     // we need an instance
>     setInstance( Kid3PartFactory::instance() );
> 
>     // this should be your custom internal widget
>     m_widget = new Editor( parent, "id3editor");
>     m_widget->setFocus();
> 
>     // notify the part that this is our internal widget
>     setWidget( m_widget);
>     m_widget->show();
> 
>     // clip more stuff
> }

But what's the "main app window" ?
Is it Konqueror, or is it an app you're writing too?
I think the bug is in the main app window, if it's yours ;)

See kdelibs/kparts/tests, there's an example of a mainwindow there.

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KDE, Making The Future of Computing Available Today


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