1

I am using dock widgets without a central widget (setCentralWidget(Q_NULLPTR)) for QOwnNotes (C++, Qt5), because you can have more complex layouts without a central widget.

My problem is that if the user resizes the application main window some more or less random dock widgets will be resized. It would be more desirable to set one specific dock widget to be resized (like the center widget would behave).

Example of the current behavior: qownnotes The left area gets resized, it would be much better if the right area (note preview in this case) would get resized.

Is there a way to force a QDockWidget to behave like a central widget when it comes to resizing the main window without actually using a central widget?

I already tried to use sizePolicy.setHorizontalPolicy, but it didn't get me there...

  • Could you provide some screenshots to show the problem? – Clearer Apr 02 '18 at 07:02
  • I added a screenshot and explanation – Patrizio Bekerle Apr 02 '18 at 07:08
  • Further examples are on https://github.com/pbek/QOwnNotes/issues/420 and all linked issues. – Patrizio Bekerle Apr 02 '18 at 07:10
  • Could you use `setFixedWidth`, `setMinimumWidth` or `setMaximumWidth`. You can calculate the width based on the size of the window after a resize. I haven't used `QOwnNotes` before, so I have no experience with it -- just writing up ideas. – Clearer Apr 02 '18 at 07:10
  • Thank you, but I already tried that. The user still needs to be able to resize the dock widgets by hand. Locking a size didn't help me... :/ – Patrizio Bekerle Apr 02 '18 at 07:13
  • 1
    It's more work and probably not a good idea, but if you have no other option, you could write a custom widget that will resize the dock widgets by dragging it and combine that with `setFixedWidth`. – Clearer Apr 02 '18 at 07:24
  • Is this a help: https://stackoverflow.com/questions/2722939/c-resize-a-docked-qt-qdockwidget-programmatically?rq=1 – Clearer Apr 02 '18 at 07:24
  • This patch may help: https://bugreports.qt.io/browse/QTBUG-55920 – Dmitry Sazonov Apr 02 '18 at 08:25
  • Or this: https://github.com/Riateche/toolwindowmanager – Dmitry Sazonov Apr 02 '18 at 08:37
  • Thank you for all the suggestions, I will take a look at them! – Patrizio Bekerle Apr 02 '18 at 18:48
  • So far I wasn't able to get anything out of the examples since all are about setting a size (which I wouldn't know when I could do that) or in the case of the toolwindowmanager (that seems to use a central widget) where QOwnNotes can already do similar things. – Patrizio Bekerle Apr 02 '18 at 19:38

0 Answers0