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

Editing a QFrame using QtDesigner



  • Hello.
    I have a system of scenes and for each scene I would like to have my own set of buttons and other things.

    Now I create a separate QFrame and consistently add the necessary widgets from the code of a specific scene.
    7207e444-988c-4bf3-a087-eeb289898ebf-image.png

    I would like to be able to create separate forms that will relate to my QFrame and load them as needed.
    How can I do this?


  • Lifetime Qt Champion

    Hi,

    Do you mean have several "scenes" and be able to switch between them like with a QStackedWidget ?



  • @SGaist,
    OK, if I'm going to use QStackedWidget, can I create a separate widget using QtDesigner?

    I want to create my own widget in QtDesigner for each scene and load them when compiling, then just switch them using QStackedWidget. Is this correct?



  • @mrjbom said in Editing a QFrame using QtDesigner:

    load them when compiling

    Not sure what you mean here. Nothing gets "loaded" while compiling.

    You can design each of your widgets as separate .ui files from Designer. These will result in separate classes in C++ code, from the uic run on the .ui files.

    It is then up to you when these get created/instantiated at run time. You can create them dynamically, when wanted, via new MyWiget1(). And you can then insert each of these into a QStackedWidget via its addWidget(QWidget *widget) method. You show any one them at a given time via QStackedWidget::setCurrentWidget(QWidget *widget).

    Does that answer what you are seeking to do?


Log in to reply