Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt-Designer, which approach to ui-files do you use?
QtWS25 Last Chance

Qt-Designer, which approach to ui-files do you use?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Panke
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      I'm using single inheritance with pointer member. It helps to keep UI outside of logic.

      1 Reply Last reply
      0
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        @denis same here

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          ++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.

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tzander
            wrote on last edited by
            #5

            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();

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              @thomas, easier to read ur code if you enclose it in between @symbols

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved