Important: Please read the Qt Code of Conduct -

How to import ui file containing frame to mainwindow?

  • Hi,
    Id like to reduce lines of code in mainwindow by seperating it to frames via seperate ui files.
    Is it correct way and is it possible to import those frames visibly to mainwindow ui file for positioning?

  • Lifetime Qt Champion


    What exactly would you like to factor out of your main window ?

  • To seperate lines of code that are created via ui designer to multiple files for improving readability.
    So far i already have very long speghtti code mainwindow , but i am planning to add even more code.
    Most is created by by clicking "go to slot..." button in ui designer.

  • Lifetime Qt Champion

    Depending on what your are putting in your main window, you should design custom widgets properly. Just loading ui files is possible but it's likely not what you want to do.

  • Easyest would be if other ui files coud be visually displayed and moved in mainwindow ui file while editing, but not sure if thats possible.

  • Lifetime Qt Champion

    If you want that, two possibilities:

    • Designer plugin
    • Widget promotion

    Easiest is the second option but you won't have the exact visual of your widget on screen.

  • @SGaist Yes promotion work flawlessly but is it possible to also visualize while editing ui or il have to use my wetware to visuzlize it?
    Is it also possible to direct the auto generated code of "go to slot..." to cpp file other than mainwindow in order to reduce lines of code in single file?

  • Lifetime Qt Champion

    If you want all the visual support then write a plugin for designer.

    If your slot only makes sense in your custom widgets then implement the slots in them.

Log in to reply