Utilizing Multiple ui files in the Same Class
-
wrote on 28 Jun 2013, 04:35 last edited by
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_OBJECTpublic:
//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?
-
wrote on 28 Jun 2013, 05:20 last edited by
All the usages of ui files can be found here: http://qt-project.org/doc/qt-5.0/qtdesigner/designer-using-a-ui-file.html
-
wrote on 28 Jun 2013, 22:56 last edited by
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.
1/3