How to get layout type from base class?
Solved
General and Desktop
-
I am supporting all the layouts by storing an instance of the base class, is there a way to determine the type of layout from the base class?
This is so I know if I can cast the base back to for example QFormLayout to allow use of the form related functions.
-
@SPlatten said in How to get layout type from base class?:
This is so I know if I can cast the base back to for example QFormLayout
You can always try to cast, if the type is wrong you'll get nullptr.
https://doc.qt.io/qt-5/qobject.html#qobject_cast -
@jsulm , I like that idea:
QFormLayout* pobjForm(qobject_cast<QFormLayout*>(pobjLayout)); QGridLayout* pobjGrid(qobject_cast<QGridLayout*>(pobjLayout)); QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(pobjLayout)); QVBoxLayout* pobjVBox(qobject_cast<QVBoxLayout*>(pobjLayout));
Simple and elegant.