Qt 弹出式菜单阴影
相关文章: 剖析QMenu & Qt完全定制化菜单
bool Menu::event(QEvent *event) { static bool class_amended = false; if (event->type() == QEvent::WinIdChange) { HWND hwnd = reinterpret_cast<HWND>(winId()); if (class_amended == false) { class_amended = true; DWORD class_style = ::GetClassLong(hwnd, GCL_STYLE); class_style &= ~CS_DROPSHADOW; ::SetClassLong(hwnd, GCL_STYLE, class_style); } } return QWidget::event(event); }
大概思路是: 在event中截获QEvent::WinIdChange事件, 然后获得窗口handle, 使用GetClassLong
/SetClassLong
去除CS_DROPSHADOW
flags, 即可去除阴影