Reputation: 24018
I have the following structure in my Qt form:
How can I completely remove the VerticalLayout_1
, so that the gridLayout_8
will became an immediate and only child of page_4
?
I tried selecting delete from the right click menu, but that deletes the childs of VerticalLayout_1
also. I also tried moving the gridLayout_8
in the drag and drop interface, but since it was the only child of the verticalLayout_1
, I just wasn't able to move it to be in page_4.
Upvotes: 1
Views: 490
Reputation: 2444
It can be tricky to select, but in the form, you should've been able to select the gridLayout_8 as a unit and drag it into the page_4 layout. That would leave the verticalLayout_1 still present, but empty, and then you can easily delete it. If the gridLayout_8 layout has zero margins, then it might be impossible to select; you would have to set the margins to something so that the border of gridLayout_8 is separated from the border of verticalLayout_1.
I drag layouts around all the time. The hard part is making the sure the layout is selected rather than something inside it. Just be prepared to undo and try again if you drop in the wrong place or grab the wrong thing.
Upvotes: 1
Reputation: 8355
One possible way would be to edit the .ui
XML file manually to remove the unneeded layout. If you open up your XML file in an editor, you should find something like this:
...
<layout class="QGridLayout" name="page_4">
<item row="0" column="0">
<!-- below is the layout you want to remove -->
<layout class="QVBoxLayout" name="verticalLayout_1">
<item>
<layout class="QGridLayout" name="gridLayout_8">
...
</layout>
</item>
</layout>
</item>
</layout>
...
In your case, you just need to remove the <layout>
tag and its <item>
child, so that the gridLayout_8
becomes a direct child of an <item>
of page_4
, i.e.:
...
<layout class="QGridLayout" name="page_4">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_8">
...
</layout>
</item>
</layout>
...
After that, you can re-open the XML file in QtCreator to make sure everything looks the way it should.
I am not sure if there is a simpler way to achieve the same result from QtCreator. If you know of any, feel free to add an answer.
Upvotes: 1