PDA

View Full Version : writing a layout manager



jayw710
15th February 2006, 17:40
Hello,

Since Qt's layouts never work for my custom widgets, I'm afraid I'm going to have to write my own:confused: .

Does anybody have an example of a custom layout manager they would be able to share? I know about the example in the documentation, but I need more (and more complex) examples.

Thank you for helping :D !

Jay

alu
15th February 2006, 22:19
Qt's layouts should work with your custom widgets just fine... if you coded them properly.

All you generally need to do is reimplement:

QSize minimumSizeHint() const;
QSize sizeHint() const;

Also, in your constructor it would be best to call setSizePolicy. You may also need to call setMaximumSize() if your widget needs it.

I make lots of custom widgets, make them into designer plugins, and then look and work great with all of Qt's layouts.

jayw710
15th February 2006, 23:53
All you generally need to do is reimplement:

QSize minimumSizeHint() const;
QSize sizeHint() const;

Also, in your constructor it would be best to call setSizePolicy. You may also need to call setMaximumSize() if your widget needs it.
I'm not saying they don't do anything, but my widgets have unique alignment needs that aren't addressed by layouts. I've reimplemented everything I can, but that doesn't fit my needs. So, I'm forced to customize the wheel for my own needs.

I see that Qt4 has a couple of more examples of custom layouts, but I only have Qt 3.3.4 and it appears some of the functions are missing. I've changed as much as I could, but stuff's missing and it won't compile.

http://support.informatik.uni-freiburg.de/manuals/qt/layout.html

Does anyone know how to make this code work in Qt 3?

Thank you!
Jay