After changing the contents directly in the setupUI function
-
If I change the ui of the .ui file after directly changing the contents in the setupUI function, the contents that I coded by myself disappear.
Is there a way to keep the hardcoded content as it is?setupUi(QWidget *wSpectrum_Setup) { scrollArea_Contents = new wSpectrum_Setup_Items(wSpectrum_Setup); }Existing wSpectrum_Setup_Items()
After the change, wSpectrum_Setup_Items(wSpectrum_Setup); -
If I change the ui of the .ui file after directly changing the contents in the setupUI function, the contents that I coded by myself disappear.
Is there a way to keep the hardcoded content as it is?setupUi(QWidget *wSpectrum_Setup) { scrollArea_Contents = new wSpectrum_Setup_Items(wSpectrum_Setup); }Existing wSpectrum_Setup_Items()
After the change, wSpectrum_Setup_Items(wSpectrum_Setup);@IknowQT "After changing the contents directly in the setupUI function" - this is not a proper title.
"after directly changing the contents in the setupUI function" - never change generated code - your changes will be gone next time code is generated!
Why do you need to change generated code?! -
@IknowQT "After changing the contents directly in the setupUI function" - this is not a proper title.
"after directly changing the contents in the setupUI function" - never change generated code - your changes will be gone next time code is generated!
Why do you need to change generated code?! -
I want to pass a pointer to wSpectrum_Setup.
When initializing, we need the information in wSpectrum_Setup -
@IknowQT As I said: do not change generated code.
You can change widgets in your forms after calling setupUi:ui->scrollArea_Contents = new wSpectrum_Setup_Items(wSpectrum_Setup);wSpectrum_Setup::wSpectrum_Setup(QWidget *parent) : m_pScroller(new usrScrollBar(this)) { ui.setupUi(this); this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); Initailize(); }Are you saying Initalize should recreate it after calling setupui? If so, isn't it that two objects are created?
-
wSpectrum_Setup::wSpectrum_Setup(QWidget *parent) : m_pScroller(new usrScrollBar(this)) { ui.setupUi(this); this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); Initailize(); }Are you saying Initalize should recreate it after calling setupui? If so, isn't it that two objects are created?
@IknowQT said in After changing the contents directly in the setupUI function:
If so, isn't it that two objects are created?
Yes, they are. Why do you want to replace it in code and not in designer -> promote widget
-
@IknowQT said in After changing the contents directly in the setupUI function:
If so, isn't it that two objects are created?
Yes, they are. Why do you want to replace it in code and not in designer -> promote widget
@Christian-Ehrlicher said in After changing the contents directly in the setupUI function:
Yes, they are. Why do you want to replace it in code and not in designer -> promote widget
because the OP's
wSpectrum_Setup_Itemsobject requieres a QWidget pointer in the constructor, AND it apparently has no default constructor and a secondary setter function for the mentioned widget -
@Christian-Ehrlicher said in After changing the contents directly in the setupUI function:
Yes, they are. Why do you want to replace it in code and not in designer -> promote widget
because the OP's
wSpectrum_Setup_Itemsobject requieres a QWidget pointer in the constructor, AND it apparently has no default constructor and a secondary setter function for the mentioned widget@J-Hilk Then the class should be changed instead adding all kind of hacks.
-
@IknowQT As I said: do not change generated code.
You can change widgets in your forms after calling setupUi:ui->scrollArea_Contents = new wSpectrum_Setup_Items(wSpectrum_Setup);