Important: Please read the Qt Code of Conduct -

Inheritance forms with QUiLoader

  • How do inheritance forms, using QUiLoader?

    @ class MainWindow : public WidgetGeneratedByLoader

            explicit MainWindow(QWidget *parent = 0);


  • Moderators

    I'm not sure what you mean, but c++ is statically typed language. This means a concept of classes or inheritance is compiled away (apart from rtti and Qt meta system).
    QUiLoader loads Uis at runtime and only instantiates already defined classes. Inheriting from dynamically loaded class would mean dynamically creating new type, which, again, c++ doesn't do.

  • I already suspected that.

    Thus, there is no way to inherit forms when using QUiLoader.


  • Moderators

    It's not clear to me what you want to do. QUiLoader creates instances of a class. You can't inherit an instance.

    You can define a custom class and create instances of it using loader.
    You can't load arbitrary .ui file with class names unknown to your program at compile time.

  • Ok,

    Thanks for the clarification

Log in to reply