PDA

View Full Version : "Desigen" Code Vs. Designer ??



jesse_mark
21st November 2012, 21:03
I have this question, and i would like to know

why most advance programmers like to design using code not designer ??

which better to design with code or designer??

I like to use the designer because :
faster,
easier
you can see you deign and modify it faster and easier.
help me to improve me design as i can see it and would help me to visualize it more.
much less code as i don't want to worry about creating all the widgets and set their attributes using code.

Please in light me with why code is better than designer, or why most advance use code and not designer ??

Thank soo much :)

amleto
21st November 2012, 22:11
from the other thread



Amleto, Yes i do use the designer, but of coruse i dont use lineedit1,...lineeditn to name my objects,I do use meaningful names.
The point is not the suitability of names, but the fact that there are so many.

If you design in designer, and then want to link lineedits to labels, you have to 'hard code' it using the variable names you gave each individual element in the designer.

If you do it in code you don't need to worry about variable names and you can set up a short factory pattern or loop that can deal with any number of elements.

e.g.

you have designed a form with a bunch of lineedits and then you need to connect them in a class ctor you end up with code like this



classX::classX()
{
QWidget* w1 = new QWidget;
connect(ui->lineedit1, SIGNAL(...), w1, SLOT(...));

QWidget* w2 = new QWidget;
connect(ui->lineedit2, SIGNAL(...), w1, SLOT(...));

QWidget* w3 = new QWidget;
connect(ui->lineedit3, SIGNAL(...), w1, SLOT(...));

QWidget* w4 = new QWidget;
connect(ui->lineedit4, SIGNAL(...), w1, SLOT(...));

QWidget* w5 = new QWidget;
connect(ui->lineedit5, SIGNAL(...), w1, SLOT(...));
}


c.f.



classX::classX()
{
for (int i = 0; i < N; ++i)
{
QLineEdit* le = new QLineEdit;
QWidget* w = new QWidget;
connect(le, SIGNAL(...), w, SLOT(...));
}
}

ChrisW67
21st November 2012, 23:38
I have this question, and i would like to know

why most advance programmers like to design using code not designer ??

There are elements of personal preference mixed in with practicality. For a simple UI it makes little difference which way you do it. Designer can be tedious when using large numbers of widgets with custom signals/slots, often faster to do connections in code. You cannot, for example, use Designer to build a UI with a parameterised number of QLineEdits, you have to do that in code. Writing a UI in code requires a better understanding of how Qt layouts work than doing the same thing in Designer.


which better to design with code or designer??
"Better" is a relative term. This is a bit like asking whether a drill press is better than a brace and bit. They can both drill basic holes, one can do it much faster and more accurately, but the other works anywhere and when the power has failed. Which is better?.. that depends on whether you are drilling a hole in a wet environment or not.

I don't think most competent programmers use code exclusively or Designer exclusively. Competent programmers evaluate the problem and possible solutions to determine how best to do something... then they choose the best-fit tool for the job.

anda_skoa
23rd November 2012, 15:11
I don't think most competent programmers use code exclusively or Designer exclusively. Competent programmers evaluate the problem and possible solutions to determine how best to do something... then they choose the best-fit tool for the job.

Exactly!
In most cases you'll have a fixed number of widgets (nothing depending on runtime values), in which case using Designer gives you the advantage of immediately seeing how it will look like.

If anyone told you that "advanced programmers" create their UIs in code instead of using the tools available for reducing development time, then they are most certainly not referring to advances in the sense of professional.

Cheers,
_