[Qt-creator] How to add a dock window to a custom editor?

Ziller Eike Eike.Ziller at theqtcompany.com
Tue Jun 16 07:52:09 CEST 2015


> On Jun 16, 2015, at 07:10, Christian Gagneraud <chgans at gna.org> wrote:
> 
> Hi there,
> 
> I have created a custom editor (a kind of drawing editor) and I would 
> like to have extra dock widgets on the left (very similar to what 
> designer offers: a property editor and a structure/hierarchy viewer).

Editors cannot add widgets to the navigation side bar in edit mode.

> I saw how it can be done when implementing a new mode (eg. the debugger 
> mode uses a custom FancyMainWindow), but I wondered if it's possible to 
> add and manage QDockWidget when implementing a custom editor as the 
> editor manager provides already something similar.
> 
> This doesn't seem possible to me, for few reasons. One of them being 
> that the editor manager provides a splitable view, which means that if i 
> use dock widget inside my editor, then the dock widgets will be inside 
> the split view - not on the side.

Putting the split issue aside, it sounds correct to me to put widgets that belong to the editor into the editor widget.
(As dock widgets or not. (Q|Fancy)MainWindows are nestable.)

> So it looks to me I will have to implement a new mode…

On the list of things that I want is that editors can specify that they want to be “maximized”, i.e. when they are activated, all splits are temporarily removed. But that doesn’t exist yet.

As long as that is not there, and since your editor is a kind of drawing editor, think about integrating your editor into Design mode like Qt Quick Designer for .qml files, and Widget Designer for .ui files. There you also control the whole area including automatic switching, without actually creating a new mode. Have a look at Core::DesignMode and how it is used.

Br, Eike

-- 
Eike Ziller, Senior Software Engineer | The Qt Company
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list