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

Christian Gagneraud chgans at gna.org
Wed Jun 17 05:52:26 CEST 2015

On 16/06/15 17:52, Ziller Eike wrote:
>> 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
> widgetsthat 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.

Yes, that would be nice to have, and in my case I would use it I think.

> 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.

Thanks for the heads up!

I had a closer look at the qml and ui designers, but I couldn't figure 
out the real advantages to hook on Core::DesignMode over the custom mode 
way. I certainly missed lot of things, but it look to me that the 
advantages are simply "the mode is already there"...

Both qml and ui designers have to implement their own layout and main 
widgets placement/management (including the OutputPane), but they don't 
use the FancyMainWindow for some reason. They both manage as well the 
switch between Edit and Design mode by providing a custom IEditor, and 
doing some sort of magic to keep things sync'ed. And both qml and ui 
designers provide a "fake" and partial IEditor toolbar (open documents 
combo box).

I might give it a try or maybe stick to the IEditor way for the sake of 
simplicity, not sure...


> Br, Eike

More information about the Qt-creator mailing list