在窗口有边框的情况下,模态窗口推动焦点会自动闪烁。但一般自定义的窗口加了下面这句:
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
隐藏了边框和标题栏。就没有这样的效果了。那么该如何实现呢?
先在自定义的QDialog的类中重构
bool nativeEvent(const QByteArray &eventType, void *message, long *result)
{
MSG *msg = static_cast< MSG * >( message );
if(msg->message == WM_NCACTIVATE)
{
bool active = (bool)(msg->wParam);
emit ncActive(active);
}