Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Best way to manage UI layout in Qt
Forum Updated to NodeBB v4.3 + New Features

Best way to manage UI layout in Qt

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 6 Posters 6.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abhisag
    wrote on last edited by
    #1

    Hi,
    We are trying to see what are the best ways to manage laying out of various child qt widgets and controls in a qt widget. As I understand this can either be done in C++ code (by using layout managers like gridlayoutmanager or VerticalBoxlayoutmanager etc) or using .ui files. Can someone please tell me which is the recommended way? I came to hear that .ui files is an old way of doing things and we should not use them? Is that accurate? Should we prefer to have layout set in code rather than in .ui file?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcrochik
      wrote on last edited by
      #2

      The UI files are just a simpler/visual way of creating the same layout managers. Unless your layout needs to be generated on the fly based on variables (platform, screen resolution, screen orientation, ...) the easier/better way to go is using UI files - Qt creator will make much easier for you to create the ui.

      Some people are erroneously referring to widgets as obsolete because the new recommended way of doing UI for mobile devices is QML. Widgets haven't been discontinued and probably will not any time soon - they are still the recommended way to develop qt applications for desktop platforms and are perfectly fine for several mobile applications.

      Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

      1 Reply Last reply
      0
      • J Offline
        J Offline
        john_god
        wrote on last edited by
        #3

        Check out the lesson nº3 in the "Qt in Education Course Material":http://qt.nokia.com/services-partners/qt-in-education/qt-in-education-course-material I find it very useful

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          I've split off the rest of this thread to "[SPLIT] Future of Widgets in Qt":http://developer.qt.nokia.com/forums/viewthread/3070/ in the general forum, as it was a topic of its own.

          But I do not want to steal "Andre's":http://developer.qt.nokia.com/member/438 valuable answer:

          [quote author="Andre" date="1294393121"] --- start ---[/quote]
          You can freely mix approaches using .ui files and hand crafted layouts even. Both have advantages and uses. If your layout is not going to be dynamic, I'd recommend using .ui files. They are not considdered "the old way" or anything like that.

          While fcochik is right, and QWidgets are not depricated, they don't currently have the focus of the Trolls anymore. Issues on Jira are being closed because of this, for instance. Still, for many situations, I think QWidgets are still way more suitable than QML. QML is nice for highly flashy UI, with smooth animations and the likes, but not so much for the typical desktop app with lots of input, buttons, menus, etc.
          [quote author="Andre" date="1294393121"] --- end ---[/quote]

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qtrahul
            wrote on last edited by
            #5

            "Using Dialogs and Handling UI layout":http://qt.nokia.com/developer/learning/qt-curriculum/qt-essentials-curriculum-block/using-dialogs-and-handling-ui-layout/

            "Layout management":http://doc.qt.nokia.com/latest/layout.html

            1 Reply Last reply
            0
            • ZlatomirZ Offline
              ZlatomirZ Offline
              Zlatomir
              wrote on last edited by
              #6

              My opinion is that there is no generic Best way of "layout-ing" the widgets.

              In the end both methods are going to be C++ code (most likely very similar C++ code).

              The only big difference is who is writing the C++ code you write it, or the UIC generate it (using the designer xml as a "pattern").

              If you want to check this just open an ui_UIFILENAME.h and see the implementation of the setupUi(...) method.

              So to choose one way or the other, you need to think of what is convenient for you: the time you need to write the code for Widgets/Layouts vs the time you need to achieve the same result using Designer.
              Basically is the same for the application/code/compiler, it only depends on what is convenient for you: what are you most productive with, or what do you like, or maybe some simple dialogs (with simple layouts) are fast to code and some more complex layouts are easier to implement in the Designer.

              https://forum.qt.io/category/41/romanian

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved