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
    {
    Q_OBJECT

    public:

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

    //functions

    private:
    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)
    :QWidget(parent),
    //initialize the ui
    ui_main(new Ui::MainSettings)
    {
    ui_main->setupUi(this);
    }

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

    //deconstructor
    SettingDialogues::~SettingDialogues()
    {
    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
    {
    Q_OBJECT@

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.