2

I'm interested in developing GUI-based Windows applications in C++, but I'm not sure how it's done in professional or large-scale settings. It seems it would take a lot of development time to describe all the elements (e.g., dimensions and such) within code.

Presumably it's not all done visually, right? How is it normally done? What methods are used to prevent a lot of time wasted on defining each and every property a UI control might have?

3
  • 1
    Visual Studio for C++ supports visual design of the User Interface. Commented Feb 13, 2012 at 6:42
  • @David It depends. For example VC++ uses resource files for the forms.
    – Searock
    Commented Feb 13, 2012 at 7:13
  • Don't ever let setting X,Y,CX,CY even cross your mind. All modern frameworks (even WinForms, though Qt still superior) allow defining relative layout. It's easier to write in code and actually usable. Setting coordinates is going to explode immediately when the user chooses bigger font (for which Windows have global setting).
    – Jan Hudec
    Commented Feb 13, 2012 at 9:45

2 Answers 2

6

Qt and wxWidgets allow you to either layout elements with an editor or with code. Like most modern guis it uses layout sizers, so instead of specifying the exact pixel coordinates of each element you just say that things are grouped into vertical sets within horizontal sets within vertical ... rather like HTML

This is necessary when you are programming for different platforms with different size controls and for mobile platforms with different sized screens and for different languages with different word lengths

3
  • 1
    It's a problem even on one platform in one language, because users can still change settings like font size and face.
    – Jan Hudec
    Commented Feb 13, 2012 at 9:29
  • @JanHudec: ... or just resize the application window.
    – sleske
    Commented Mar 16, 2012 at 11:46
  • @sleske: You can prevent resizing window in the design. True, users will doubt your sanity, but even Microsoft often does. Well, not that Microsoft was an example of good UI designers.
    – Jan Hudec
    Commented Mar 16, 2012 at 11:56
2

Most modern GUI frameworks use some kind of interface description language, basically a domain-specific language, to describe the GUI.

Qt has QML, Windows Presentation Foundation has XAML, Gnome uses Glade XML files, and so on.

Most of the modern web development frameworks are also declarative (Java Server Faces, ASP .NET), not only because they are based on HTLM (which is declarative), but also because they use pre-made components which are referenced by name in the page.

Many of these frameworks also have visual GUI designers, but many developers prefer to write the GUI in an editor, because it gives better control. At the same time, declarative GUI code is much less verbose than creating GUI widgets in code.

See e.g. this question for examples of declarative GUI languages:

https://stackoverflow.com/questions/2962874/what-are-the-open-source-alternatives-to-wpf-xaml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.