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

qml 启用 frameless 后,双击 titlebar 不能最大化窗口 #95

Open
hanxipu opened this issue Jun 6, 2024 · 2 comments
Open

qml 启用 frameless 后,双击 titlebar 不能最大化窗口 #95

hanxipu opened this issue Jun 6, 2024 · 2 comments
Labels
invalid This doesn't seem right

Comments

@hanxipu
Copy link

hanxipu commented Jun 6, 2024

set(QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT ON CACHE BOOL "")
set(QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS OFF CACHE BOOL "")

CMakelists.txt

set(QWINDOWKIT_BUILD_STATIC ON CACHE BOOL "")
set(QWINDOWKIT_BUILD_WIDGETS OFF CACHE BOOL "")
set(QWINDOWKIT_BUILD_QUICK ON CACHE BOOL "")
set(QWINDOWKIT_ENABLE_QT_WINDOW_CONTEXT ON CACHE BOOL "")
set(QWINDOWKIT_ENABLE_WINDOWS_SYSTEM_BORDERS OFF CACHE BOOL "")

# Add subdirectories
add_subdirectory(qwindowkit)

# Set project source files
set(PROJECT_SOURCES
    main.cpp
    qml/main.qml
    qml/QWKButton.qml
    qml/qml.qrc
    resources/qwk.qrc
)

# Add executable based on Qt version
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
  qt_add_executable(${PROJECT_NAME}
    MANUAL_FINALIZATION
    ${PROJECT_SOURCES}
  )
else()
  add_executable(${PROJECT_NAME}
    ${PROJECT_SOURCES}
  )
endif()

# Configure target
qm_configure_target(${PROJECT_NAME}
    QT_LINKS Core Gui Qml Quick
    LINKS QWKQuick
)

main.qml

    WindowAgent {
        id: windowAgent
    }

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.LeftButton

        onDoubleClicked: {
            if (window.visibility === Window.Maximized) {
                window.showNormal()
            } else {
                window.showMaximized()
            }
        }
    }

这个双击事件只在 icon 上产生效果,其他位置不生效

@hanxipu
Copy link
Author

hanxipu commented Jun 6, 2024

现在是注释掉

        // Component.onCompleted: windowAgent.setTitleBar(titleBar)

然后自己实现来解决这个问题

@wangwenx190
Copy link
Collaborator

你给的main.qml代码片段太短,就几行,我们怎么分析?

一定要仔细看README。被设置为标题栏的item,所有交互事件都会被接管,也就是不再会响应任何鼠标事件了。如果你想让标题栏内的控件继续响应鼠标事件,要手动setHitTestVisible。

@wangwenx190 wangwenx190 added the invalid This doesn't seem right label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants