KDAB / KDDockWidgets

KDAB's Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets
Other
747 stars 163 forks source link

How to set affinity? #465

Closed petrmanek closed 5 months ago

petrmanek commented 5 months ago

Hi, I am trying to use affinities with the QtQuick platform and the latest revision of KDDW 2.0 and have a quick question. How and at what point in object lifecycle do you set them? All QML wrappers have affinities declared only as a readonly property, which proxies to the wrapped object (usually a DockWidget or a MainWindow) or an empty list if it is not defined.

I was able to subclass KDDockWidgets::QtQuick::ViewFactory and set DockWidget affinity inside createDockWidget(), however this seems super hacky and it does not give me an easy way to do the same for main windows. An obvious place to do this setup cleanly would be somewhere in MainWindowInstantiator or a DockWidgetInstantiator.

Can you please advise? Am I missing something here?

petrmanek commented 5 months ago

I suspect this is a low-hanging fruit / undocumented feature. I tried to search through examples and other issues, but could not find anything material. Could I please get any of the developers/maintainers to chime in? @iamsergio

iamsergio commented 5 months ago

I'll get to this soon, currently traveling

iamsergio commented 5 months ago

yeah, API needs to be exposed

petrmanek commented 5 months ago

@iamsergio Note that I am happy to help with a PR, if that is desirable. I would like to use affinities to load/save only a subset of windows and widgets.

iamsergio commented 5 months ago

MainWindowInstantiator, DockWidgetInstantiator and LayoutSaverInstantiator have an affinities property now, it takes a list. See tests/main465.qml

petrmanek commented 5 months ago

Thanks for implementing this so fast! :tada:

One last question: I have noticed that the referenced commit appears in the mdi_fixed_size_example branch. I am currently running KDDW from the 2.0 branch. What is the difference between those branches, and are there any plans to merge them in the future?

iamsergio commented 5 months ago

It's in main now. mdi_fixed_size_example is something else, to be deleted

petrmanek commented 5 months ago

It's in main now. mdi_fixed_size_example is something else, to be deleted

Are you sure about this? I have just switch back from mdi_fixed_size_example to 725d146796b1382c52180b61ac5f3652a3d688f3, which is the latest commit in 2.0 as of writing, and this does not seem to be included.

petrmanek commented 5 months ago

Please disregard my last comment. I have only noticed now that there is a main branch. (I was assuming that you were referring to 2.0 when you wrote "main")