stdware / qwindowkit

Cross-platform frameless window framework for Qt. Support Windows, macOS, Linux.
Apache License 2.0
550 stars 89 forks source link

基于MainWindow示例代码新增QVideoWidget后导致标题栏无法拖动窗口 #32

Open LeoLei8060 opened 8 months ago

LeoLei8060 commented 8 months ago

After adding a QVideoWidget object to the QWKExample_MainWindow project, I encountered an issue where clicking and dragging the title bar does not move the window. The code is as follows:

MainWindow::MainWindow(QWidget *parent) 
: QMainWindow(parent), m_videoWidget(new QVideoWidget(this)), m_player(new QMediaPlayer(this)) {
    installWindowAgent();

    //auto clockWidget = new ClockWidget();
    //clockWidget->setObjectName(QStringLiteral("clock-widget"));
    //clockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    //setCentralWidget(clockWidget);

    setCentralWidget(m_videoWidget);
    m_player->setVideoOutput(m_videoWidget);

    loadStyleSheet(Dark);

    setWindowTitle(tr("Example MainWindow"));
    resize(800, 600);
}

After invoking the QMediaPlayer::setVideoOutput interface, there are issues with the window's title bar area, as well as problems with window rendering. However, if you resize the window vertically by dragging the top or bottom borders, the mouse can once again move the window by dragging the title bar area. I encountered the same issue with a simple custom frameless window implementation I had developed earlier. I haven't identified the specific cause yet and hope you can provide a solution.

LeoLei8060 commented 8 months ago

I just tested the FramelessHelper library and found that adding QVideoWidget does not cause this issue. I'm curious about the differences in the underlying implementations of the two libraries.

wangwenx190 commented 8 months ago

FramelessHelper has many workarounds but they are not quite related the "frameless" keyword, so we removed many of them in this new project. But some of them may fix some weird issues. And QVideoWidget internally is embeding a QWindow into the QWidget to display video images, this embeded QWindow may cause issues such as confuse our native event handling logic.

wangwenx190 commented 8 months ago

But indeed this needs to be fixed. I'll investigate it

mitosuzu commented 8 months ago

@wangwenx190 我遇到了同样的问题,当我放入的窗口中包含QAxWidget时,在程序界面最大化一次后,标题栏的拖动和双击最大最小化失效。

SineStriker commented 7 months ago

@onecodeWorld24 现在还有这个问题吗?

mitosuzu commented 7 months ago

@onecodeWorld24 现在还有这个问题吗?

出现多余标题栏的解决了,但经过一次窗口大小的变化后(最大化或窗体边缘拖拽改变大小),标题栏的双击最大最小化和拖拽移动就失效了。 image

SineStriker commented 7 months ago

@onecodeWorld24 现在还有这个问题吗?

出现多余标题栏的解决了,但经过一次窗口大小的变化后(最大化或窗体边缘拖拽改变大小),标题栏的双击最大最小化和拖拽移动就失效了。 image

你的qt和系统版本?

mitosuzu commented 7 months ago

@SineStriker Qt 5.15.2,win11,Windows SKD是10.0

SineStriker commented 7 months ago

@SineStriker Qt 5.15.2,win11,Windows SKD是10.0

确实,很复杂。。。得花点时间研究下了。

mitosuzu commented 7 months ago

@onecodeWorld24 现在还有这个问题吗?

出现多余标题栏的解决了,但经过一次窗口大小的变化后(最大化或窗体边缘拖拽改变大小),标题栏的双击最大最小化和拖拽移动就失效了。 image

51 通过设置QGuiApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings) 这里不能拖动的问题也解决了