Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Designer; difficulty placing widgets in the right parent

Tags:

qt

qt-designer

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?

like image 732
Taco de Wolff Avatar asked Sep 21 '10 19:09

Taco de Wolff


2 Answers

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.

like image 110
Caleb Huitt - cjhuitt Avatar answered Nov 18 '22 22:11

Caleb Huitt - cjhuitt


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.

like image 40
jkerian Avatar answered Nov 18 '22 23:11

jkerian