如何获得一个窗口框架的颜色?

我正在尝试读取常规窗口的窗口边框(框架)的颜色。

看来, window->palette().color(QPalette::XXXX)会做到这一点,但什么是XXXX ? 或调色板不可能? 如果是这样,怎么样?

你需要使用它原生的GetSysColorBrush函数:

 QColor getWindowFrameColor() { // This is the only way to detect that a given color is supported HBRUSH brush = GetSysColorBrush(COLOR_ACTIVEBORDER); if (brush) { DWORD color = GetSysColor(COLOR_ACTIVEBORDER); return QColor(GetRValue(color), GetGValue(color), GetBValue(color)); // calling DeleteObject(brush) is unnecessary, but would be harmless } return QColor(); } 

我已经搜索了COLOR_ACTIVEBORDER的Qt源COLOR_ACTIVEBORDER ,唯一的方法是通过在WebKit上运行一些自定义的JavaScript代码来检索它。