4
votes

I have a problem with QDockWidget. I'm using Qt Designer, and I would like to build an app with only dock-widgets, and have a small bar above for properties. The problem is that I cannot build the app without a main QWidget (I mean with only QDockWidgets).

Here is my screenshot:

qtdesigner

Annotation 1) - this is the space that I can't remove. When I remove it from xml, Qt Designer crashes. If it is not removable, how can I set the left QDockWidget and the right QDockWidget to have half of the entire window width?

4
You probably have a unused row in your gridlayout in the centralWidget. Clear the layout and set it up once more. This time make sure you do not have a empty row. If I had to guess, you had all buttons directly on mainwindow before, leaving you with 7 rows. You then moved them into own widgets? leaving you with a lot of unused rows spanned by the button on the bottom...Sebastian Lange
I have edited my post and attached screen link for better quality. Whole Screen is 3 try to build this thing. And No, buttons where added to QDocWidget only. There are 3 button to check how much I can expand QDocWidget. QWidget - Responsible for for that space was added by Designer automatically. I have cleaned CentralWidget - now there is red circle. End it didnt hide, and after resizing it is expanding but QDocWidget stays the same. I would like to have oposite : )Przemek Lewandowski
Even I tried to have 3 widgets. Top, Left and Bottom there is space with that QWidget. Even if I set 1x1 px width it expands in Designer ! :)Przemek Lewandowski

4 Answers

2
votes

You can remove centralWidget using setCentralWidget(0);

1
votes

This cannot be done from within Qt Designer. However, there is a Qt Forum Thread which suggests there may be a way to do it programmatically.

Firstly, you have to set the main-window dockNestingEnabled property to true in Qt Designer. Then, after you create the ui, programmatically delete the central widget, and then also remove, re-add and re-show all the dock widgets.

When I tested this, I found that I needed to show the dock-widgets with a single-shot timer, otherwise I couldn't resize them vertically. However, even with that little hack, I still found that resizing doesn't always work properly. So I'm not convinced that Qt really supports this way of using dock-widgets.

0
votes

After creating GUI in Qt Designer and translating it to ui_file. Add one line in your __init___ call script:

self.ui.centralwidget.hide()

you may need to check if your central widget is called the as above

0
votes

Remove all references to the central widget:

pyuic5 -x uifile.ui -o main.py
sed -i /centralwidget/d main.py

Running python3 main.py should get you the desired behaviour.