PDA

View Full Version : Inheriting Custom Decorated Dialog



dcrespo
18th October 2012, 01:29
Hi,

I'm trying to create a custom dialog with a border width and color. This dialog I want it to be inherited by others, so other developers don't have to deal with the border or other decorations we would need down the road.

My first approach is to create a MyDialog : public QDialog, private Ui::MyCustomDialog (multiple inheritance way), since I want to be able to add stuff to it. One thing I think it should have is a place where to stick child widgets into. For example, an empty layout, where I would set the child widget into, so it resizes properly. The problem is that I have no idea on how to make ANY child widget to be inserted into the layout automatically.

Any ideas? Thanks.
-Daniel

wysota
18th October 2012, 13:18
It's easiest if you just give your class a "setWidget" method accepting a widget instance. Then people can call that method passing a complete widget with layouts and child widgets. And the method would just place the received instance in a layout of the dialog. Similar thing is done by QScrollArea.