tags:

views:

44

answers:

2

Using the Qt Designer I've made a couple of QFrames in each other, each having a horizontal layout. Their stylesheet predicates that they should have no margin nor a padding. This means that in the Qt Designers view as well as in the final result, no space is seen between the QFrames.

Using drag-and-drop I can place widgets into the window, it shows a blue line where it will be placed (in a layout). However, it's impossible to add another QFrame to a QFrame parent I can't see (and thus drop on). There is also a tree in the right panel, but dropping on the parent makes it automatically go in one of the childs...

Example, I have this setup:

QMainWindow
- QWidget
  - QFrame (parent)
    - QFrame (child)
    - QFrame (child)

Adding a new frame, whatever I try, gives me:

QMainWindow
- QWidget
  - QFrame (parent)
    - QFrame (child)
    - QFrame (child)
    - QFrame (new child)

But I really want:

QMainWindow
- QWidget
  - QFrame (parent)
    - QFrame (child)
    - QFrame (child)
  - QFrame (new parent)

Is there any feature I haven't discovered to accurately place new widgets?

+2  A: 

You can use the Object Inspector window, but you don't seem to be able to paste into a QFrame that has a locked layout.

So given your layout:

QMainWindow
- QWidget
  - QFrame (A)
    - QFrame (B)
    - QFrame (C)
    - QFrame (D)

Select QFrame D in the Object Inspector window and Cut it, right click QWidget and Break the layout (ctrl-0), then paste. Then re-apply the layout.

jkerian
Changing layouts and adding frames and widgets can definitely be a pain. Breaking the layout is usually what is required depending on what you are trying to change. As a trick, sometimes I use designer to create a temp form/widget. This can act like a clipboard for cutting and pasting groups of components back and forth.
Arnold Spence
This works yes, thank you. It does undo the layout for QWidget this way, which I have to re-configure, or is that inevitable?
Daevius
@Arnold, yes that works nicely, thank you!
Daevius
A: 

One workaround I've used is to select the widget I want to be adding to, add a margin to that widget's layout, drag and drop the widget, then remove the margin again. This way, at least I get it in the correct widget.

Caleb Huitt - cjhuitt