PDA

View Full Version : Up this topic if you wanna QDesigner with an Anchors property!



thiforums
1st April 2009, 18:36
As the topic says, let's up this topic until the next version of QDesigner comes with the property Anchors for each visual QT control, so we don't need to waste days learning how to draw layouts by trying and testing until the thing becomes good. What an annoying task and waste of time, huh? Even coding the GUI is easier than using QDesigner in some cases.

What does Anchors property mean?
The purpose of an Anchors property is to set, as the name suggests, the anchors (Top/Bottom/Left/Right) of a given visual control. With Anchors you don't need to set any layouts because it will do the job automatically for you. It will resize the controls (eg: inside a QDialog) when you resize the dialog itself. It's a very easy way to design a GUI and it must be part of the next version of QDesigner. Things will become much more easier to design window applications.
The Anchors property idea is took from Borland IDEs (Delphi/C++Builder). If you already used one of them you know that the anchors property is very usefull when designing GUIs.

Note: The purpose of this topic is not to clean QT from using layouts, but just to add a new property that will let the developer to choose if he wanna suffer with layouts or to use the anchors property and be very happy!

Up!

Boron
1st April 2009, 19:03
The layout mechanism is THE heavenly advantage of Qt compared to all other GUI libs I have seen so far.

Some months ago I tried to improve a C# app, written by a colleague at work. My goal was to have a proper handling of the GUI elements when the window is resized.
Whatever this library is called, that provides the GUI elements, I found it really annoying to work with theses "anchor" things (the elements have some sort of properties telling that the element is "sticked" at the e.g. bottom of another element).
I gave my best, but when the dialog window was scaled down everything was a mess. Some buttons were pushed below text boxes and therefore invisible until the window was made bigger again.

I decided not to use C# (and all related languages) for apps providing a GUI. It must be bare horror to create a GUI that can be resized and "feels good" in such a language.

Working with layouts in Qt is different to what other libraries provide concerning "layouting". But it is far more advanced to anything else!
Get used to it and you will learn to love it.

wysota
1st April 2009, 23:52
What does Anchors property mean?
The purpose of an Anchors property is to set, as the name suggests, the anchors (Top/Bottom/Left/Right) of a given visual control. With Anchors you don't need to set any layouts because it will do the job automatically for you. It will resize the controls (eg: inside a QDialog) when you resize the dialog itself. It's a very easy way to design a GUI and it must be part of the next version of QDesigner. Things will become much more easier to design window applications.

I'm sorry to say that but the "anchor" solution is one of the worst methods of positioning elements within a container. It has no flexibility and it is very error prone. There are many situations which simply can't be expressed with such a mechanism ( such as relative dimensions and non-trivial layouts). Try to express a layout such as the one in the attachment using this mechanism. It's not that simple and it's a single click using the layouts paradigm.


The Anchors property idea is took from Borland IDEs (Delphi/C++Builder). If you already used one of them you know that the anchors property is very usefull when designing GUIs.

Borland C++ environment is the worst C++ development environments I have ever seen. Sorry for being so blunt but I really think so.


Note: The purpose of this topic is not to clean QT from using layouts, but just to add a new property that will let the developer to choose if he wanna suffer with layouts or to use the anchors property and be very happy!

You don't have to modify Qt to be able to do that, you can implement it with the already provided functionality. Either implement a simple layout where you can specify alignment of items (there already is a similar layout implementation available - it is called "border layout" and as far as I remember it is one of the examples that come with Qt) or use the grid layout where specifying alignments is already possible.