CBubbleFrame::CBubbleFrame(QWidget *parent)
: QFrame(parent)
{
ui.setupUi(this);
setWindowOpacity(1);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint| Qt::Popup);
setAttribute(Qt::WA_TranslucentBackground);
}
重写事件方法:
virtual bool event(QEvent *event);
bool CBubbleFrame::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); // windows系统函数
}
}
return QWidget::event(event);
}