此頁麵包含的信息有關 Qt for Windows .
把 Qt 安裝到帶空格的目錄下,例如 C:\Program Files ,可能導緻 qmake 齣現問題。
把 Qt 安裝到不帶空格的子目錄下,能避免此問題。
The Win32 API that both Qt and compiler tools use has a built-in maximum file path length of 260 characters (
MAX_PATH
). This can hit you in various forms if either your absolute or relative directory structures are too verbose. It is therefore recommended to keep the file system paths within limits, and put build directories nearby the source directories.
若使用修改 Structure 和 Union 成員對齊的特殊標誌時遇到奇怪問題 (譬如
/Zp2
) 那麼就需要采用為應用程序設置的標誌重新編譯 Qt。
當窗口使用基於 OpenGL 的錶麵並以全屏方式齣現時,屬於應用程序的其它頂層窗口可能發生問題。由於 Windows DWM (桌麵窗口管理器) 的局限性,基於 OpenGL 的窗口閤成未被正確處理,當進入全屏模式時。因此,其它頂層窗口不會被放置在全屏窗口的頂部,當它們變得可見時。例如,菜單可能未正確齣現,或對話框無法展示。
窗口可以明確使用基於 OpenGL 的錶麵,當 setSurfaceType () is called, or when something that requires OpenGL is used inside the window, causing the whole window to be OpenGL based. For example, QOpenGLWidget or QQuickWidget 可以觸發這。不管怎樣,若錶麵包含在 QWindow 其托管采用 createWindowContainer (), or the obsoleted QGLWidget is used and it does cover the entire full screen window, then this problem does not occur.
To solve this problem, native APIs can be used to enable the
WS_BORDER
attribute when showing in full screen mode. This can be utilized as follows:
bool Widget::event(QEvent *e) { #if defined(Q_OS_WIN) if (e->type() == QEvent::WinIdChange) { if (windowHandle()) { HWND handle = reinterpret_cast<HWND>(windowHandle()->winId()); SetWindowLongPtr(handle, GWL_STYLE, GetWindowLongPtr(handle, GWL_STYLE) | WS_BORDER); } } #endif return QWidget::event(e); }
這將給予全屏窗口 1 像素邊框,從而使其它頂層窗口能夠齣現在頂部。
Qt 使用
OLE
on Windows to be able to support functionality like dragging or clipboard access. To use OLE, Qt has to call
OleInitialize
. This in turn will set the thread's concurrency model to
COINIT_APARTMENTTHREADED
.
調用
CoInitializeEx
or
winrt::init_apartment
on the UI thread and specifying a concurrency model other than single-threaded apartment (
COINIT_APARTMENTTHREADED
or
winrt::apartment_type::single_threaded
, respectively) might lead to bugs or application hangs.