Giter Site home page Giter Site logo

Comments (9)

SineStriker avatar SineStriker commented on June 8, 2024

QSizePolicy only works when the widget is in a layout because you can't disable the user from resizing the window by setting a fixed size policy when you use a plain Qt window, so FramelessHelper shouldn't do this as well. It's a mistake that FramelessHelper made, we have removed it in QWindowKit. You should use setFixedSize or set Qt::MSWindowsFixedSizeDialogHint flag.

from qwindowkit.

Ikok9c6s avatar Ikok9c6s commented on June 8, 2024

I forget to say that I need to change the feature (whether user can resize window by dragging borders or not) frequently when the window is shown.
And after testing two methods you mentioned above, I think neither of the two methods is appropriate.
Reasons are as follows.
For setFixedSize : after calling it, QWidget::resize can't work, so I need to call resizeor setFixedSize according to property resizable, it's cumbersome and when downstream developers cast the dialog as QWidget or QDialog, it gets worse. Any way, the feature is not equal to fixedSize, it should be anything like user-fixed.
For Qt::MSWindowsFixedSizeDialogHint: if you change windowFlags when the window is visible, it will hide because setParent is called in it. And the worst part is once the flag is set, a resize error occurs in dpi scale when move window between screens(tested in 1920*1080 100% and 150%).
image

from qwindowkit.

Ikok9c6s avatar Ikok9c6s commented on June 8, 2024

I agree with you that the feature has nothing to do with QSizePolicy, so could you please just add a flag to describe it and expose the api to change it separately?

from qwindowkit.

SineStriker avatar SineStriker commented on June 8, 2024

I agree with you that the feature has nothing to do with QSizePolicy, so could you please just add a flag to describe it and expose the api to change it separately?

我认为你应该在正常的Qt窗口里尝试你想要的功能,如果正常窗口都没有这种功能,那么QWK也不会实现,没有必要实现这种多余的功能。

from qwindowkit.

Ikok9c6s avatar Ikok9c6s commented on June 8, 2024

我之前就是在WM_NCHITTEST中根据是否允许用户resize的flag,选择性进行HTLEFT等边框的判断。
QWK处理了WM_NCHITTEST并且没有给使用者提供修改的方式,这个功能的确和QWK无关,但是QWK也限制了使用者处理该消息,这是否不太合理呢?

from qwindowkit.

SineStriker avatar SineStriker commented on June 8, 2024

Author

你的意思是,你在自己的全局nativeEventFilter或者窗口重写的nativeEventFilter中处理了WM_NCHITTEST,处理结果仍然会被QWK的覆盖是吗?

from qwindowkit.

Ikok9c6s avatar Ikok9c6s commented on June 8, 2024

调试下来是这样的,QWKHookedWndProc执行在Qt的qWindowsWndProc之前

from qwindowkit.

SineStriker avatar SineStriker commented on June 8, 2024

你说的这个确实是个问题,我想办法做一些修改让你能继续处理你的事件。

from qwindowkit.

SineStriker avatar SineStriker commented on June 8, 2024

代码已提交,你可以试试看在你的窗口中重写nativeEvent,类似如下逻辑,应该可以禁止用户调整大小。

bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) {
    Q_UNUSED(eventType)

    auto msg = reinterpret_cast<MSG *>(message);
    if (msg->message == WM_NCHITTEST) {
        auto &res = *result;
        if (res >= HTLEFT && res <= HTBOTTOMRIGHT) {
            res = HTBORDER;
            return true;
        }
    }
    return false;
}

from qwindowkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.