NuMs
1st December 2017, 10:53
Hello!
Trying to learn QT.
My current project has one GUI and I need to be able to access elements of the UI from subclasses. None of the subclasses have a UI.
How do I pass Ui::MainWindow to subclasses? Basically they need to be able to update labels or text fields.
I've tried to pass it through the constructor like below:
SubClass::SubClass(Ui::MainWindow mw) {
this->mw = mw;
}
With it defined in the header file:
class SubClass {
public:
SubClass(Ui::MainWindow mw);
Ui::MainWindow mw;
}
Which of course doesn't work. I'm guessing there's a proper way to do this but I haven't been able to find it in any of the tutorials or documentation.
Any help would be appreciated.
Thanks
Trying to learn QT.
My current project has one GUI and I need to be able to access elements of the UI from subclasses. None of the subclasses have a UI.
How do I pass Ui::MainWindow to subclasses? Basically they need to be able to update labels or text fields.
I've tried to pass it through the constructor like below:
SubClass::SubClass(Ui::MainWindow mw) {
this->mw = mw;
}
With it defined in the header file:
class SubClass {
public:
SubClass(Ui::MainWindow mw);
Ui::MainWindow mw;
}
Which of course doesn't work. I'm guessing there's a proper way to do this but I haven't been able to find it in any of the tutorials or documentation.
Any help would be appreciated.
Thanks