Qt-Designer, which approach to ui-files do you use?
-
wrote on 11 Jul 2010, 18:22 last edited by
The documentation offers three ways to use the ui files in your application in a static way.
Since I am just starting my journey with Qt, I would like to know, if you prefer single or multiple inheritance? Are you consistent throughout your programs or do you decide this on a case-by-case basis? If yes, what do you take into consideration? -
wrote on 11 Jul 2010, 19:03 last edited by
I'm using single inheritance with pointer member. It helps to keep UI outside of logic.
-
wrote on 9 Aug 2010, 13:48 last edited by
@denis same here
-
wrote on 9 Aug 2010, 19:21 last edited by
++pointer_member_method;
When i use designer i use that method too.
I always keep the pointer private (code the necessary signals/slots for that purpose)The multiple inheritance "saves" you from "extra" coding, but it's not really keeping the generated code separated from the code you write.
-
wrote on 9 Aug 2010, 20:39 last edited by
My preference is this;
class MyWidget : public QWidget { public: MyWidget() { widget.setupUi(this); } private: Ui::MyWidget widget; }
The advantage is that this makes sure any changes in your UI file will will not cause conflicts in variable usage inside your 'MyWidget' class which is something that may happen if you double inherit.
The advantage of using the 'widget' as a member instead of as a pointer is one less 'new' and no need to do a 'delete' (which is so easy to forget and sometimes causes mem leaks).
Last; I really like the way of accessing this code in my class;
widget.mySpinbox->value();
-
wrote on 10 Aug 2010, 07:41 last edited by
@thomas, easier to read ur code if you enclose it in between @symbols