How to add a layout to QWidget using designer?
-
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 -
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. :)
-
@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.
-
@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 theuic
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.
-
Good point to note yes. I will think about it.
-
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.
-
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. -
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.
:)