Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Support for child windows? #33

Closed
skarndev opened this issue Nov 5, 2020 · 15 comments
Closed

Support for child windows? #33

skarndev opened this issue Nov 5, 2020 · 15 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@skarndev
Copy link

skarndev commented Nov 5, 2020

Is there any support for non-top level windows? I specifically mean the widgets that show up in a separate window and QDockWidget titlebar when undocked.

So far the whole library is the best out of all frameless QT solutions on Github! Looking great, but would be nice to handle the children as well.

Screen Shot 2020-11-05 at 11 41 48 AM

@wangwenx190
Copy link
Owner

Child windows may be supported. I just didn't test child windows.

@wangwenx190
Copy link
Owner

By the way, what do you want to tell me by showing this picture?

@wangwenx190
Copy link
Owner

Child windows may be supported. I just didn't test child windows.

You can try to make the child windows frameless. If it doesn't work, you can tell me and I'll see if there's a good solution.

@skarndev
Copy link
Author

skarndev commented Nov 5, 2020

By the way, what do you want to tell me by showing this picture?
Just the fact that it does not affect the child titlebars. (And as I understood from your answer, it should not by default). There is a QWidget with Tool and StaysOnTopHint in the middle, and two QDockWidgets set floating. For QDockWidget I tried calling FramelessWindowsManager::addWindow(&widget) as well. but it does not work. Should I maybe put a connection to QDockWidget's undock event and only addWindow when undock has occured?

@wangwenx190
Copy link
Owner

Should I maybe put a connection to QDockWidget's undock event and only addWindow when undock has occured?

I'm not quite sure about this. Actually, on non-Windows platforms, I'm using the Qt::FramelessWindowHint flag to get rid of the title bar. You can try to enable that flag for a normal QDockWidget and a QWidget with Tool and StaysOnTopHint to see if they can become frameless. If they can become frameless indeed, then I need to check my code to see what's wrong.

@wangwenx190 wangwenx190 self-assigned this Nov 14, 2020
@wangwenx190 wangwenx190 added enhancement New feature or request help wanted Extra attention is needed labels Nov 14, 2020
@bighzl
Copy link

bighzl commented Dec 29, 2020

创建一个非top-level的子window后,原来的top-level window就抓不到WM_NCHITTEST,大概是在

const QWindow *window = findWindow(msg->hwnd);
    if (!window || (window && !window->property(m_framelessMode).toBool())) {
        return false;
    }

这个地方被返回了。一旦抓不到WM_NCHITTEST事件后,window窗口的title area就开始响应鼠标事件了,这在正常的时候是不会响应的。

@wangwenx190
Copy link
Owner

创建一个非top-level的子window后,原来的top-level window就抓不到WM_NCHITTEST,大概是在

const QWindow *window = findWindow(msg->hwnd);
    if (!window || (window && !window->property(m_framelessMode).toBool())) {
        return false;
    }

这个地方被返回了。一旦抓不到WM_NCHITTEST事件后,window窗口的title area就开始响应鼠标事件了,这在正常的时候是不会响应的。

不是顶层窗口的话就没有QWindowfindWindow这个函数会返回空指针,在你标出来的这个地方确实会直接返回。

但这里我想要确保msg->hwnd这个句柄是一个独立的窗口,而不是一个控件,我暂时不知道有什么更好的方法。用Win32 API的话,我试过IsWindowGetParentGetAncestor等函数,都没法很好的区分窗口和控件,而且Qt还会创建一些不可见的窗口来实现一些特别的功能,也会对这些API的效果造成很大的影响。至于Qt自己的API,确实有isTopLevelisWindow等函数,但这都是QWidget特有的函数,Qt Quick是用不了的,而且还会引入QtWidgets这个依赖项,不太可行。

如果不管msg->hwnd是不是一个独立的窗口,直接无脑应用无边框的代码,我也试过,最终效果不好,也不可行。

你知道有什么比较好的办法能判断一个句柄是不是一个独立的窗口吗?

@Flip20
Copy link

Flip20 commented May 10, 2021

Hi there,

great work, finally a pretty good frameless lib for our Qt app. Is there an update in the support for child windows, in particular QDockWidgets? I can make them frameless (when floating), give them a custom title bar, but FramelessWindowsManager::addIgnoreObject(..) seems not to work on them and QPushButtons on this title bar do not respond. My Chinese is bad, so maybe I missed something in this thread.

Philip

@wangwenx190
Copy link
Owner

maybe I missed something in this thread

No you didn't.

Is there an update in the support for child windows, in particular QDockWidgets?

Currently no, I'm sorry but currently I don't know a practical solution.

FramelessWindowsManager::addIgnoreObject(..) seems not to work

Because they are not top level windows, so all the events will be ignored by FramelessHelper. In one word, the root cause is, on Win32 platform, it's really hard to tell whether a HWND is a top level window or a child widget, without pulling in the QtWidgets dependency. I've tried Win32 APIs but they don't work well in such situations.

@Flip20
Copy link

Flip20 commented May 11, 2021

Ok, thanks! Found out that I probably do not need the FramelesWindowsManager for the QDockWidgets, I can set a custom titlebar for them the moment they start floating, which makes the standard Windows bar disappear. From the Qt doc:

If a title bar widget is set, QDockWidget will not use native window decorations when it is floated.

@wangwenx190
Copy link
Owner

Ok, thanks! Found out that I probably do not need the FramelesWindowsManager for the QDockWidgets, I can set a custom titlebar for them the moment they start floating, which makes the standard Windows bar disappear. From the Qt doc:

If a title bar widget is set, QDockWidget will not use native window decorations when it is floated.

Thanks for telling me this! I've updated the README file to mention about it.

@Flip20
Copy link

Flip20 commented May 12, 2021 via email

@Flip20
Copy link

Flip20 commented May 12, 2021

The problem lies in my QVTKWidget2, see also

dfct/TrueFramelessWindow#13

@wangwenx190
Copy link
Owner

@Flip20 Sorry I'm not sure about it either.

@wangwenx190
Copy link
Owner

Should be fixed in 2.0. closing for now. feel free to reopen it if necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants