Skip to content

Conversation

@hulswit
Copy link

@hulswit hulswit commented Aug 20, 2020

Added option to set a dock widget as central widget. It influences resizing behavior of the splitter. The central widget will be stretched with the main window and remaining dock widgets and their respective areas will be resized only vertically if docked left or right and horizontally if docked top or bottom.

Adde option to set a dock widget as central widget. It influences resizing behavior of the splitters. The central widget will be stretched with the main window and remaing dock widgets and threir respective areas will be resized only vertically if docked left or right  and horizontaly if docked top or bottom
Copy link
Owner

@githubuser0xFFFF githubuser0xFFFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the review comments - Thank you

auto TargetAreaSizes = TargetAreaSplitter->sizes();
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
NewSplitter->addWidget(TargetDockArea);
// updateSplitterHandles(NewSplitter);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally uncommented?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update happens two line later, so this one can be removed.

{
if(d->CentralWidget)
{
addDockWidget(RightDockWidgetArea, d->CentralWidget);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain, what you do here. If there is already a CentralWidget then you move it into the RightDockWidgetArea and make the new widget the central one - is this right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I guess I can add a parameter containing possible DockWidgetArea for existing Central widget with default being RightDockWidgetArea.

Copy link
Owner

@githubuser0xFFFF githubuser0xFFFF Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really like this implicit moving of the previous widget into another dock area. Especially if you implement the change below, where you clear the floatable, movable and closable flags. Then you move a non floatable, non closable and non movable dock widget into another area.

I would propose, that an old central widget is removed and returned to the caller if a new widget is assigned. So the function would look like this:

CDockAreaWidget* CDockManager::setCentralWidget(CDockWidget* widget, CDockWidget** oldWidget = nullptr)

So the oldWidget parameter is for returning the old central widget. Normally the user should never assign a central widget if there is already one assigned. But if the old one is returned, the caller at least has a chance to set the dock widget flags properly.

What do you think about this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

d->CentralWidget = widget;
return addDockWidget(CenterDockWidgetArea, widget);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A central widget should be not closable, not flotable and not movable and the dock area title bar should be hidden. In your example you set all these properties outside before you call this function.

What do you think about settings these properties here inside. That means, if someone sets a central widget, this function clears the movable, floatable and closable features and hides the title bar of the created dock area?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. I am adding this there now.


#include <QLCDNumber>

class CDigitalClock : public QLCDNumber
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all fixed height widgets from the example (the top one and the bottom status bar) and remove the digitalclock source files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure...

Updated the setting of central widget with option to set where the possible old central widget will be placed. Fixed option of "unsetting" central widget by setting it to nullptr.
@githubuser0xFFFF
Copy link
Owner

I just merged your pull request with some changes and fixes. Thank you.

@githubuser0xFFFF
Copy link
Owner

There seems to be a problem with your central widget implementation. It seems like the central widget will not be saved and restored properly when saving and restoring state (see the issues for more details)

I will remove the central widget concept within the next days from the library and hope, that you can provide a fixed implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants