PDA

View Full Version : custom QLayout help



Micawber
19th October 2007, 22:19
I am trying to implement a custom QLayout. I am using the card example in the Layout Classes page for a start. I noticed that the Qt supplied layouts allow nested layouts via the addLayout() method. I need to add both widgets and child layouts in my custom layout. How should I implement the addLayout method? The example doesn't cover this and I couldn't find any info by searching the forum.

Thanks for any help.

Mic

wysota
19th October 2007, 22:28
QLayout doesn't have such method, so you don't need to implement it. Instead it has addItem() method that you should probably reimplement. If you keep working on QLayoutItem level, you'll be able to implement addLayout() through addItem().

Micawber
19th October 2007, 22:44
Ok I'm a dolt! Thanks wysota for making me look a little harder.

It seems that QLayout inherits from QLayoutItem and that I can just call addItem() passing the pointer to the child layout that I want without the compiler flying out at me.

I had already reimplemented it from the example, but was confused since it was expecting QLayoutItem pointers and I was wanting to add a QVBoxLayout!

It compiles at least. Testing later.

Thanks!