Results 1 to 4 of 4

Thread: "Desigen" Code Vs. Designer ??

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default "Desigen" Code Vs. Designer ??

    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

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: "Desigen" Code Vs. Designer ??

    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

    Qt Code:
    1. classX::classX()
    2. {
    3. QWidget* w1 = new QWidget;
    4. connect(ui->lineedit1, SIGNAL(...), w1, SLOT(...));
    5.  
    6. QWidget* w2 = new QWidget;
    7. connect(ui->lineedit2, SIGNAL(...), w1, SLOT(...));
    8.  
    9. QWidget* w3 = new QWidget;
    10. connect(ui->lineedit3, SIGNAL(...), w1, SLOT(...));
    11.  
    12. QWidget* w4 = new QWidget;
    13. connect(ui->lineedit4, SIGNAL(...), w1, SLOT(...));
    14.  
    15. QWidget* w5 = new QWidget;
    16. connect(ui->lineedit5, SIGNAL(...), w1, SLOT(...));
    17. }
    To copy to clipboard, switch view to plain text mode 

    c.f.

    Qt Code:
    1. classX::classX()
    2. {
    3. for (int i = 0; i < N; ++i)
    4. {
    5. QLineEdit* le = new QLineEdit;
    6. QWidget* w = new QWidget;
    7. connect(le, SIGNAL(...), w, SLOT(...));
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. The following user says thank you to amleto for this useful post:

    jesse_mark (29th November 2012)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: "Desigen" Code Vs. Designer ??

    Quote Originally Posted by jesse_mark View Post
    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.

  5. The following user says thank you to ChrisW67 for this useful post:

    jesse_mark (29th November 2012)

  6. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: "Desigen" Code Vs. Designer ??

    Quote Originally Posted by ChrisW67 View Post
    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,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    jesse_mark (29th November 2012)

Similar Threads

  1. Replies: 4
    Last Post: 11th August 2011, 09:02
  2. Running example project with mingw gives "... exited with code -1073741792" error
    By sibercekirge in forum Installation and Deployment
    Replies: 8
    Last Post: 31st May 2011, 18:33
  3. Replies: 4
    Last Post: 5th January 2011, 16:51
  4. Replies: 3
    Last Post: 2nd November 2010, 23:36
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.