窗口设置为Qt::Popup时, 如何去掉窗口阴影?
2014-08-16 16:00
761 查看
转自:http://blog.csdn.net/robertkun/article/details/38081081
[cpp] view
plaincopy
CFlowerWid::CFlowerWid(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Popup);
setAttribute(Qt::WA_TranslucentBackground);
}
窗口设置为Qt::Popup时, window7下会自带一个阴影.
如何去掉窗口阴影?
代码:
[cpp] view
plaincopy
bool CFlowerWid::event(QEvent *event)
{
// class_ameneded 不能是custommenu的成员, 因为winidchange事件触发时, 类成员尚未初始化
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);
}
需要执行Windows函数,
[cpp] view
plaincopy
SetClassLong(hwnd, GCL_STYLE, class_style);
记录一下, 免得忘了.
[cpp] view
plaincopy
CFlowerWid::CFlowerWid(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::Popup);
setAttribute(Qt::WA_TranslucentBackground);
}
窗口设置为Qt::Popup时, window7下会自带一个阴影.
如何去掉窗口阴影?
代码:
[cpp] view
plaincopy
bool CFlowerWid::event(QEvent *event)
{
// class_ameneded 不能是custommenu的成员, 因为winidchange事件触发时, 类成员尚未初始化
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);
}
需要执行Windows函数,
[cpp] view
plaincopy
SetClassLong(hwnd, GCL_STYLE, class_style);
记录一下, 免得忘了.
相关文章推荐
- 窗口设置为Qt::Popup时, 如何去掉窗口阴影?
- 提示窗口(Alert)、弹出窗口去掉弹出后阴影的样式设置
- [WPF] 如何为无边框窗口设置阴影效果
- qt中如何去掉主窗口标题栏
- qt中如何去掉主窗口标题栏
- Qt如何设置窗口屏幕居中显示以及设置大小
- Qt for Symbian中如何添加头文件路径和打包文件|Qt 窗口外边框设置。
- Qt如何设置窗口的背景图片?
- Qt编程—去掉标题栏和设置窗口透明用法
- QT中窗口如何隐藏最大话按钮 和设置背景图片
- qt中如何去掉主窗口标题栏
- Qt如何设置窗口的背景图片
- [WPF] 如何为无边框窗口设置阴影效果
- Qt编程—去掉标题栏和设置窗口透明用法
- Qt编程—去掉标题栏和设置窗口透明用法
- [WPF] 如何为无边框窗口设置阴影效果
- qt中如何去掉主窗口标题栏
- Activty 设置成窗口样式后 如何去掉ActionBar
- qt中如何去掉主窗口标题栏
- Qt 4中如何为对话框设置背景?说说我总结的方法