Skip to content
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

How to make floating window with fixed size #345

Closed
pklaffert opened this issue Feb 23, 2023 · 11 comments
Closed

How to make floating window with fixed size #345

pklaffert opened this issue Feb 23, 2023 · 11 comments
Assignees

Comments

@pklaffert
Copy link

I want to have a floating window with a fixed size

    ```
   auto w = newMyWidget();
   auto dock = new KDDockWidgets::DockWidget(QStringLiteral("new dock %1").arg(count),
                       KDDockWidgets::DockWidget::Option_NotDockable);
    
    w->setFixedSize(600, 600);                       // Does not make the size fixed
    dock->setWidget(w);         
    dock->setFixedSize(600, 600);                  // Does not make the size fixed
    dock->show();

    dock->window()->setFixedSize(600, 600); // Does not make the size fixed
    ```

How can I achieve this?

@pklaffert pklaffert changed the title How to make dockwidget with How to make dockwidget with fixed size Feb 23, 2023
@pklaffert pklaffert changed the title How to make dockwidget with fixed size How to make floating window with fixed size Feb 23, 2023
@iamsergio
Copy link
Contributor

Hi,

Can you try kddockwidgets_example -g

That calls: myWidget->setMaximumSize(200, 200); which works
Replacing with myWidget->setFixedSize(200, 200); works as well.

Maybe there's an edge case where this doesn't work. Ideally please show through modifying the example (attach a patch that I can repro).

Or maybe it's platform specific, we'll find out.

@iamsergio iamsergio self-assigned this Feb 24, 2023
@pklaffert
Copy link
Author

Hi Sergio,

myWidget->setMaximumSize works. What does not work is to have a fixed size floating window.

not-fixed

I am using kddw 1.7 from today on windows 10

@iamsergio
Copy link
Contributor

So you're saying, if you edit MyMainWindow.cpp , and replace "setMaximumSize" with "setFixedSize" it stops working ?

I've tried on Windows 10 / Qt 5 / KDDW-1.7 latest , and both work, floating window is not resizable past its max

Do you have maybe other changes in MyMainWindow.cpp that are conflicting ?

@pklaffert
Copy link
Author

No. No other changes. Clean build. Using Qt 5.15.1 and KDDW in release build.

@iamsergio
Copy link
Contributor

Can you:

  • Checkout branch test/345
  • Build and run the example (no -g needed, it's implied in this test)
  • Make dockwidget 8 float, then make it have a too big size
  • Press the "dump debug" button
  • Paste the results here (qDebug statements are printed to the terminal)

@pklaffert
Copy link
Author

pklaffert commented Mar 1, 2023

Widget:  QRect(0,0 250x250) QSize(250, 250) QSize(-1, -1) QSize(250, 250) QSize(-1, -1) KDDockWidgets::FloatingWindowWidget(0x2a09a44f0a0)
TLW   :  KDDockWidgets::FloatingWindowWidget(0x2a09a44f0a0) QRect(97,412 1000x762) QSize(262, 292) QSize(262, 292) QSize(262, 292) QSize(262, 292)
Window   :  QWidgetWindow(0x2a09a6dd010, name="KDDockWidgets::FloatingWindowClassWindow") QRect(104,412 986x755) QRect(97,412 1000x762) QSize(262, 292) QSize(262, 292) QRect(104,412 986x755) QFlags<Qt::WindowType>(Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint)



@iamsergio
Copy link
Contributor

This is even more strange, as your floating windows have Qt::Window instead of Qt::Tool.

The example might be picking some other KDDW dll you have, possible patched with different Config::flags() ? please double check.

meanwhile I'll prepare another round of debug info to figure this out :)

@pklaffert
Copy link
Author

This time I did a fresh clone of the kddw repo:

Widget:  QRect(0,0 250x250) QSize(250, 250) QSize(-1, -1) QSize(250, 250) QSize(-1, -1) KDDockWidgets::FloatingWindowWidget(0x2c0c164a030)
TLW   :  KDDockWidgets::FloatingWindowWidget(0x2c0c164a030) QRect(97,412 704x638) QSize(262, 292) QSize(262, 292) QSize(262, 292) QSize(262, 292)
Window   :  QWidgetWindow(0x2c0c16a8b20, name="KDDockWidgets::FloatingWindowClassWindow") QRect(104,412 690x631) QRect(97,412 704x638) QSize(262, 292) QSize(262, 292) QRect(104,412 690x631) QFlags<Qt::WindowType>(Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint)

Same results.

iamsergio added a commit that referenced this issue Mar 3, 2023
@iamsergio
Copy link
Contributor

ok, please pull test/345 again (should be 3e6e090) and repeat please
there will new debug info printed

@pklaffert
Copy link
Author

Flags:  QFlags(0x2) QFlags()
Widget:  QRect(0,0 250x250) QSize(250, 250) QSize(-1, -1) QSize(250, 250) QSize(-1, -1) KDDockWidgets::FloatingWindowWidget(0x2922b8e6920)
TLW   :  KDDockWidgets::FloatingWindowWidget(0x2922b8e6920) QRect(97,412 501x475) QSize(262, 292) QSize(262, 292) QSize(262, 292) QSize(262, 292)
Window   :  QWidgetWindow(0x292295c0ee0, name="KDDockWidgets::FloatingWindowClassWindow") QRect(104,412 487x468) QRect(97,412 501x475) QSize(262, 292) QSize(262, 292) QRect(104,412 487x468) QFlags<Qt::WindowType>(Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint)

@iamsergio
Copy link
Contributor

Thank you, that helped me track down a local problem. My example for some reason was running with "compatibility for windows 8".

Disabling that, I've now reproduced your problem

iamsergio added a commit that referenced this issue Mar 6, 2023
If width is fixed and height is not, then when using the corner resize
only width can be changed (and same for fixed height).

Fixes #345

(cherry-picked from commit 1b33da8)
iamsergio added a commit that referenced this issue Mar 8, 2023
For issue #345

(cherry picked from commit f6d9ac5)
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

No branches or pull requests

2 participants