【问题标题】:Can't open maximized window using Qt4 over RDP (RemoteApp)无法使用 Qt4 over RDP(RemoteApp)打开最大化窗口
【发布时间】:2017-01-24 10:28:29
【问题描述】:

我正在使用 PyQt4 4.11.4 (Qt 4.8.7) 和 Python 2.7.12 编写应用程序。使用 RemoteApp(内置 Windows 远程桌面服务)运行它时,我无法让窗口以最大化状态打开:它在几个(单个?)帧中显示为最大化,并立即跳转到恢复状态。 重现错误的代码:

from PyQt4.QtGui import QApplication, QDialog
from PyQt4.QtCore import Qt
import sys


app = QApplication(sys.argv)
w = QDialog()
w.setWindowFlags(Qt.Window)
w.showMaximized()
w.show()
sys.exit(app.exec_())

无法使用 Python 2.6.4 和 Qt 4.5.3 重现错误(应用程序是使用 PyInstaller 构建的,我找不到获取 PyQt 版本的方法)。

我发现的唯一提到的类似错误(不确定是否相同)是here

这个错误有什么解决办法吗?我不考虑使用旧版 Qt 作为解决方案。

UP1: 上面用 C++ 重写的 sn-p 产生了相同的行为,所以这是一个 Qt 错误。

UP2: Qt 4.8 中的 Windows 具有 WS_POPUPWS_combine_POPUPWINDOW 样式,而在 Qt 4.5 中则没有。修复 this one 时可能引入的错误。

UP3: 是的,问题在于WS_POPUP 风格。手动删除后,窗口保持最大化:

...
HWND hWnd = w.winId();
long style = GetWindowLong(hWnd, GWL_STYLE);
SetWindowLong(hWnd, GWL_STYLE, style & ~WS_POPUP);
...

正在搜索不同的方法来删除它...

【问题讨论】:

    标签: python qt qt4 pyqt4 remoteapp


    【解决方案1】:

    通过恢复此补丁并重建 Qt 解决了问题:

    diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
    index 39ed750..c358b9b 100644
    --- a/src/gui/kernel/qwidget_win.cpp
    +++ b/src/gui/kernel/qwidget_win.cpp
    @@ -329,18 +329,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
             if (topLevel) {
                 if ((type == Qt::Window || dialog || tool)) {
                     if (!(flags & Qt::FramelessWindowHint)) {
    -                    if (!(flags & Qt::MSWindowsFixedSizeDialogHint)) {
    +                    style |= WS_POPUP;
    +                    if (!(flags & Qt::MSWindowsFixedSizeDialogHint))
                             style |= WS_THICKFRAME;
    -                        if(!(flags &
    -                            ( Qt::WindowSystemMenuHint
    -                            | Qt::WindowTitleHint
    -                            | Qt::WindowMinMaxButtonsHint
    -                            | Qt::WindowCloseButtonHint
    -                            | Qt::WindowContextHelpButtonHint)))
    -                            style |= WS_POPUP;
    -                    } else {
    -                        style |= WS_POPUP | WS_DLGFRAME;
    -                    }
    +                    else
    +                        style |= WS_DLGFRAME;
                     }
                     if (flags & Qt::WindowTitleHint)
                         style |= WS_CAPTION;
    @@ -424,6 +417,14 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
                 if (!q->testAttribute(Qt::WA_Resized)) {
                     w = sw/2;
                     h = 4*sh/10;
    +                if (extra) {
    +                    int dx = rect.right - rect.left;
    +                    int dy = rect.bottom - rect.top;
    +                    w = qMin(w, extra->maxw + dx);
    +                    h = qMin(h, extra->maxh + dy);
    +                    w = qMax(w, extra->minw + dx);
    +                    h = qMax(h, extra->minh + dy);
    +                }
                 }
                 if (!wasMoved) {
                     x = sw/2 - w/2;
    

    找到here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      相关资源
      最近更新 更多