-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply layout of one set of dockwidgets to a different set #470
Comments
I don't have a better answer than those workarounds, the use case is a bit exotic. If you have access to DockWidget_p.h you can change d->affinities yourself, if you are aware of possible edge cases (I listed a few). I'm tempted to allow changing affinities if the dock widget is currently closed. |
Actually, my first idea cannot work. I cannot make the So currently, I have only the second idea, where I replace the unique names (and affinities) within the serialized layout. Generally speaking, the layout is transferred from one set of dockwidgets to another set of dockwidgets, simply using a mapping between the unique names. I think this could be a feature of the layout_saver = LayoutSaver()
# Generalize the layout; Could also use this final names if they are known at this point of time
layout_saver.use_mapping( { "MW_0" : "MW_x",
"DW_0_A": "DW_x_A",
"DW_0_B": "DW_x_B" } )
generalized_layout = layout_saver.serializeLayout()
...
layout_saver = LayoutSaver()
layout_saver.use_mapping( { "MW_x" : "MW_1",
"DW_x_A": "DW_1_A",
"DW_x_B": "DW_1_B" } )
layout = layout_saver.restoreLayout(generalized_layout) This would need to be extended, to have one mapping for the unique-names and one for the affinities. |
I have the following use case, for which I couldn't find a nice solution.
My starting situation is as follows, I have an arbitrary number of
MainWindow
s (MW_0
,MW_1
, ...). For each of thoseMainWindow
s, there is a fixed number ofDockWidget
s, say for example two, which all have an affinity to this oneMainWindow
. For simplicity I use theuniqueName
of theDockWidget
s as affinity-string.For example there could be two
MainWindow
sMW_0
andMW_1
and fourDockWidget
s:DW_0_A
,DW_0_B
with affinity toMW_0
andDW_1_A
,DW_1_B
with affinity toMW_1
.Now, this is what I would like to achieve: I want to save the layout of all
DockWidgets
belonging to for exampleMW_0
, which areDW_0_A
,DW_0_B
.And in a second step, I would like to apply this saved layout to a different group of
DockWidget
s, for exampleDW_1_A
,DW_1_B
.My first idea, was to use
LayoutSaver::setAffinityNames
and to change the affinities of theDockWidget
s temporarily. This means just before I want to save or restore their layout I change the affinities, just to change it back again afterwards.For example, if I want to save the layout of
DW_0_A
andDW_0_B
, I would change their affinity string from "MW_0" to "MW_x", then I would create aLayoutSaver
, set its affinity also to "MW_x", save the layout and then change the affinities ofDW_0_A
andDW_0_B
back to "MW_0" again.This doesn't work, because one cannot change the affinities of a
DockWidget
.I don't know if this case is a good justification to allow this, you tell me ;)
But in my opinion, it would be kind of a hacky solution with this changing of affinities back and forth.
I found a different workaround, which is even more ugly: I modify the
uniqueNames
within the serialized layout. In combination withLayoutSaver::setAffinityNames
, I can "transfer" the layout of one set ofDockWidget
s to another.The text was updated successfully, but these errors were encountered: