Important: Please read the Qt Code of Conduct -

Utilizing Multiple ui files in the Same Class

  • Hi there, so I have a custom widget ui and a custom dialog ui that I've created in Qt Designer. And I'm trying to initialize and create both of them using the same class. This is what I have:

    @class SettingDialogues :public QWidget


    //constructor, deconstructor
    SettingDialogues(QWidget *parent = 0, Qt::WindowFlags f = 0 );
    SettingDialogues(QDialog *parent = 0);


    Ui::MainSettings *ui_main; //dynamic pointer object's for ui
    Ui::SubSettings *ui_sub; //<- want to declare another one, not working though@

    And in my cpp file I have something like this:

    @SettingDialogues::SettingDialogues(QWidget *parent, Qt::WindowFlags f)
    //initialize the ui
    ui_main(new Ui::MainSettings)

    SettingDialogues::SettingDialogues(QDialog *parent)
    //initialize the ui
    ui_sub(new Ui::SubSettings)
    ui_sub->setupUi(this); //<-Compiler doesn't like this. :(

    delete ui_main;

    I was hoping I didn't need to create a whole 2nd class for the SubSettings dialog box. Help?

  • Thanks, didn't quite have the information I was looking for, but I managed to figure it out with some trial and error. I ended up just creating another class as I cannot have the declaration of my class have this:
    class SettingDialogues :public QWidget

    And still work with QDialog, I have to pick one apparently.

Log in to reply