PDA

View Full Version : QWidget Attachments



BingoMaster
26th September 2009, 14:54
I am currently working in Windows environment but want to port to MacOS and Unix (Linux). I am from the old school and actually worked on XWindows on the RS-6000 and HP-Unix (1992-1995) using X11.

I was wondering if Qt has the equivalent to attachtop, attachleft, attachright…

This was wonderful when doing resizing, because your widgets would keep in alignment when resizing the form.

I been reading and can’t find anything about attachments, but seem like it should be implemented.

Thank you in advance.

franz
26th September 2009, 15:16
Qt has the concept of layouts, which is usable on any supported platform. As far as I can see, the layout system is at least just as powerful as the attach* functions.

BingoMaster
26th September 2009, 16:08
I am working in Qt Creator, and I notice the 4 types of layouts. But did they every mess up my layout. Maybe I need a better place on describing the layout then the help files.

franz
27th September 2009, 20:42
In my experience designer is good for simple layouting. If you need complex stuff (e.g. excessive column or row spanning) you really should code it yourself.



QGridLayout *layout = new QGridLayout;

QPushButton *b = new QPushButton("some text", this);

layout->addWidget(b, 0, 0, 1, 1);

this->setLayout(layout);

wysota
27th September 2009, 21:07
But did they every mess up my layout.

You probably just used them incorrectly. The most important thing to remember is that you apply layouts to parent of the widgets you want to be controlled. So at least you have to apply the layout to the form itself by clicking inside it (so that no other widgets are selected) and clicking one of the layout icons in the toolbar. Of course you can nest layouts by applying a layout to a subset of widgets first and then on the top-level form.