qwindowkit icon indicating copy to clipboard operation
qwindowkit copied to clipboard

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

Open LeoLei8060 opened this issue 1 year ago • 10 comments

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 avatar Jan 28 '24 12:01 LeoLei8060

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.

LeoLei8060 avatar Jan 28 '24 13:01 LeoLei8060

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 avatar Jan 30 '24 01:01 wangwenx190

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

wangwenx190 avatar Jan 30 '24 02:01 wangwenx190

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

mitosuzu avatar Feb 22 '24 06:02 mitosuzu

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

SineStriker avatar Feb 23 '24 05:02 SineStriker

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

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

mitosuzu avatar Feb 23 '24 06:02 mitosuzu

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

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

你的qt和系统版本?

SineStriker avatar Feb 23 '24 09:02 SineStriker

@SineStriker Qt 5.15.2,win11,Windows SKD是10.0

mitosuzu avatar Feb 23 '24 09:02 mitosuzu

@SineStriker Qt 5.15.2,win11,Windows SKD是10.0

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

SineStriker avatar Feb 23 '24 14:02 SineStriker

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

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

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

mitosuzu avatar Mar 05 '24 03:03 mitosuzu