Skip to content

DockManager: add the ability to programmatically update splitter sizes #266

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

Merged
merged 1 commit into from
Oct 23, 2020

Conversation

chris-se
Copy link

Add the ability to programmatically update splitter sizes. The user must
specify the dock area that is contained in a splitter and a list of
sizes. The list of sizes will be passed to the splitter that immediately
contains the specified dock area. If the dock area is not part of a
splitter the method will have no effect.

Add the ability to programmatically update splitter sizes. The user must
specify the dock area that is contained in a splitter and a list of
sizes. The list of sizes will be passed to the splitter that immediately
contains the specified dock area. If the dock area is not part of a
splitter the method will have no effect.
@nickdademo
Copy link

We did something similar in our app. The function we added was something like this: setDockLayoutSizes(const QList<QWidget*> areas, const QList<int> sizes) - allowing you to actually set the size of each splitter area for each dock area. This PR is a good start but IMO is missing the ability to know which dock area splitter size you are actually setting in setSplitterSizes().

@chris-se
Copy link
Author

The main reason I needed this was to provide a useful initial layout -- I'm not using the method to change things after the user has been able to drag stuff around. For that ADS would require quite a bit more introspection capabilities (or the user would have to manually look at parent/child relationships of widgets). And in the initial layout case I do know what area is where, so I do know for what area I'm calling the method here.

Hence the current patch does what I need -- but I'd be happy to implement a better version if you have a useful idea for the semantics. For example, I don't quite get the semantics of the setDockLayoutSizes() you mentioned just from the function signature.

@nickdademo
Copy link

setDockLayoutSizes() is called something like this:

setDockLayoutSizes({topLeftDockArea, centralDockArea, topRightDockArea}, {80, 200, 80});

  1. Then we do something like: auto *splitter = findCommonParent<QSplitter*>(areas);
  2. Then for each area: auto index = getSplitterWidgetIndex(splitter, area)
  3. Then we can create the QList<int> in the correct order that QSplitter::setSizes() requires.

So as you can see, there is no need to know the actual order of the areas, the function handles it.

I still think this PR is useful as it is anyway :) I just wanted to share how it could be extended perhaps.

@githubuser0xFFFF
Copy link
Owner

Thank you for your contribution.

@githubuser0xFFFF githubuser0xFFFF merged commit 0e3c3ba into githubuser0xFFFF:master Oct 23, 2020
luelista pushed a commit to luelista/Qt-Advanced-Docking-System that referenced this pull request Mar 22, 2022
githubuser0xFFFF#266)

Add the ability to programmatically update splitter sizes. The user must
specify the dock area that is contained in a splitter and a list of
sizes. The list of sizes will be passed to the splitter that immediately
contains the specified dock area. If the dock area is not part of a
splitter the method will have no effect.

Co-authored-by: Christian Seiler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants