Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

UI Generation Question



  • Hello all, hope all is well. I just had a quick question regarding the code that is used to construct the UI elements of an application. If you are not using ui files, is it a better coding practice to generate the ui within the header file or within the source file?


  • Moderators

    @WesLow said in UI Generation Question:

    is it a better coding practice to generate the ui within the header file or within the source file?

    Source file. Probably in your constuctor.

    The header file should contain your class structure, not your logic.



  • @WesLow said in UI Generation Question:

    If you are not using ui files

    Just curious, do you have a compelling reason not to use ui files?
    I mean for maintainability point of view, let's say you add a new programmer to the team, I guess it'll be easier and quicker for that person to use Qt Designer and change the GUI than dig into the GUI generation code...



  • UI file is the view(V) of MVC model in GUI design. Better to use it for easier maintenance purpose.


  • Lifetime Qt Champion

    Hi
    Just so it's clear.
    Using UI files is only a Design feature.
    They are converted to code and hence there is no runtime cost or
    any hidden magic. You also get an automatic way of resetting the texts
    if a new Translator is loaded.


Log in to reply