Originally Posted by
codeslicer
The "fancy" design is completely different, the only things that are the same are the object names...
You mean like the form layout is completely different? I suppose you could use single inheritance approach and have two different ui members:
#include "ui_plainwidget.h"
#include "ui_fancywidget.h"
class MyFancyWidget
: public QWidget{
...
private:
Ui::FancyWidget fancyUi;
Ui::PlainWidget plainUi;
};
void MyFancyWidget::setFancyMode()
{
saveFormState(); // you might want to store contents if you let user to change mode on the fly
qDeleteAll(children()); // or something like this to clear everything, it is important to delete layout()
fancyUi.setupUi(this);
restoreFormState(); // restore contents
}
void MyFancyWidget::setPlainMode()
{
...
plainUi.setupUi(this);
...
}
#include "ui_plainwidget.h"
#include "ui_fancywidget.h"
class MyFancyWidget : public QWidget
{
...
private:
Ui::FancyWidget fancyUi;
Ui::PlainWidget plainUi;
};
void MyFancyWidget::setFancyMode()
{
saveFormState(); // you might want to store contents if you let user to change mode on the fly
qDeleteAll(children()); // or something like this to clear everything, it is important to delete layout()
fancyUi.setupUi(this);
restoreFormState(); // restore contents
}
void MyFancyWidget::setPlainMode()
{
...
plainUi.setupUi(this);
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks