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. How to add a layout to QWidget using designer?

How to add a layout to QWidget using designer?

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 18.1k 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.
  • T Offline
    T Offline
    Tapsa
    wrote on last edited by
    #1

    Hi all! I came back to Qt Creator after 6 months break and I forgot the most important basics of Qt Designer. I need to add a layout to QWidget tab object so its contents will fill the whole tab at all times. Here is an image that explains what I try to achieve.
    http://imgur.com/Tz9sUYx

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Suji
      wrote on last edited by Suji
      #2

      Hi @Tapsa !

      It seems that your "map_layout" is not included inside your "tab_research". No ?

      If i understand what you need, I'm doing like this :

      .

      //Create the QTabWidget
      QTabWidget m_tabWid = new QTabWidget(this);
      
      //Create tabs
      QWidget m_tab1 = new QWidget;
      
      //Create a boxlayout (vertical here)
      QVBoxLayout vbox = new QVBoxLayout;
      
      //Set the layout for your tab
      m_tab1->setLayout(vbox);
      
      //If you want to add widgets into your tab1
      vbox->addWidget();
      
      //Add tabs to the QTabWidget
      m_tabWid->addTab(m_tab1, "Settings");
      

      .

      QTabWidget>>layout>>tabs>>otherobjects

      Hope I understood what you actually need. It is without Designer, but maybe that can help you, waiting another answer. :)

      1 Reply Last reply
      0
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        @Tapsa
        Hello,
        Select the widgets you want in the layout and click with the right mouse button and there's a "Lay out >" submenu, choose one of the layouts that suit you.

        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tapsa
          wrote on last edited by Tapsa
          #4

          @Suji said:

          //Set the layout for your tab
          m_tab1->setLayout(vbox);

          I want to do this with the designer, but right-click menu of tab widgets has no layout options. Even tab_research has no layout options even though it has a layout. The designer is extremely counter intuitive. Obviously there is a need for a layout inside tab widgets, but nothing intuitive (like dragging layout on top of it or right-click menu) works.

          EDIT: I found the layout options in the top of the designer view.

          EDIT2: The layout options in the top are unrealiable. They may or may not change the layout of current tab or the whole main frame.

          kshegunovK 1 Reply Last reply
          0
          • T Tapsa

            @Suji said:

            //Set the layout for your tab
            m_tab1->setLayout(vbox);

            I want to do this with the designer, but right-click menu of tab widgets has no layout options. Even tab_research has no layout options even though it has a layout. The designer is extremely counter intuitive. Obviously there is a need for a layout inside tab widgets, but nothing intuitive (like dragging layout on top of it or right-click menu) works.

            EDIT: I found the layout options in the top of the designer view.

            EDIT2: The layout options in the top are unrealiable. They may or may not change the layout of current tab or the whole main frame.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by kshegunov
            #5

            @Tapsa
            As I noted you can use the context menus.

            1. Setting a layout to a widget:
              widget layout

            2. Setting a grid layout to a tab in a tab widget:
              tab widget page layout
              resulting in:
              tab widget page layout result

            It only takes some getting used to.
            Kind regards.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            4
            • S Offline
              S Offline
              Suji
              wrote on last edited by
              #6

              Hi @Tapsa,

              Glad to hear so ! That's why I don't like to build a project into Designer, like you said : it's not intuitive in my opinion, and people always warned me to not use it, because you don't control all you're doing.

              Wish you a good day !

              kshegunovK 1 Reply Last reply
              0
              • S Suji

                Hi @Tapsa,

                Glad to hear so ! That's why I don't like to build a project into Designer, like you said : it's not intuitive in my opinion, and people always warned me to not use it, because you don't control all you're doing.

                Wish you a good day !

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @Suji
                Hello,
                You could build the UI however you like, it's a personal choice and a preference. To this statement
                "That's why I don't like to build a project into Designer, like you said : it's not intuitive in my opinion, and people always warned me to not use it, because you don't control all you're doing.", however, I have to strongly object!
                Everything you code by hand is generated automatically from the uic that parses the form, with the added ability to actually see what you're doing in the designer. Although, one thing you should know to use the tool effectively is how layouts/widgets are nested. Once you grasp that the designer is incredibly powerful, allowing for rapid creation of almost anything.

                Kind regards.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  Suji
                  wrote on last edited by
                  #8

                  @kshegunov

                  Good point to note yes. I will think about it.

                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    I must also second @kshegunov
                    that Designer is very powerful for designing and its not a all or nothing.

                    You can easy mix Designer and in code gui generation for maximum flexibility.

                    1 Reply Last reply
                    2
                    • T Offline
                      T Offline
                      Tapsa
                      wrote on last edited by
                      #10

                      I decided and started to create my GUI with C++ code only.
                      Thanks for the tips, especially kshegunov. I tried to get that right-click menu from the list on right. I fail to grasp the logic why the right-click menu is different between clicking the design view and clicking the object list. It is very annoying and hard to create large scale windows with hundreds of controls using the designer.

                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Well, navigating a project with
                        hundreds of controls created from code will also be
                        very verbose and hard.

                        I like Designer a lot and have around 40 screen with many controls.
                        Having that as code would be awful.

                        Designer has flaws yes, but also many nice features.
                        :)

                        1 Reply Last reply
                        1

                        • Login

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