运行环境:framebuffer、armlinux系统、qt5.4
设置这两句
setAttribute(Qt::WA_TranslucentBackground);
setWindowFlags(Qt::FramelessWindowHint);
//通过这个接口可以发现
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83void MissionMark::PrintWindowFlags() { QString text; Qt::WindowFlags flags = this->windowFlags(); Qt::WindowFlags type = ( flags & Qt::WindowType_Mask); if (type == Qt::Window) { text = "Qt::Window"; } else if (type == Qt::Dialog) { text = "Qt::Dialog"; } else if (type == Qt::Widget) { text = "Qt::Widget"; } else if (type == Qt::ForeignWindow) { text = "Qt::ForeignWindow"; } else if (type == Qt::SubWindow) { text = "Qt::SubWindow"; } else if (type == Qt::CoverWindow) { text = "Qt::CoverWindow"; } else if (type == Qt::Desktop) { text = "Qt::Desktop"; } else if (type == Qt::Sheet) { text = "Qt::Sheet"; } else if (type == Qt::Drawer) { text = "Qt::Drawer"; } else if (type == Qt::Popup) { text = "Qt::Popup"; } else if (type == Qt::Tool) { text = "Qt::Tool"; } else if (type == Qt::ToolTip) { text = "Qt::ToolTip"; } else if (type == Qt::SplashScreen) { text = "Qt::SplashScreen"; } if (flags & Qt::MSWindowsFixedSizeDialogHint) text += "n| Qt::MSWindowsFixedSizeDialogHint"; if (flags & Qt::X11BypassWindowManagerHint) text += "n| Qt::X11BypassWindowManagerHint"; if (flags & Qt::FramelessWindowHint) text += "n| Qt::FramelessWindowHint"; if (flags & Qt::NoDropShadowWindowHint) text += "n| Qt::NoDropShadowWindowHint"; if (flags & Qt::WindowTitleHint) text += "n| Qt::WindowTitleHint"; if (flags & Qt::WindowSystemMenuHint) text += "n| Qt::WindowSystemMenuHint"; if (flags & Qt::WindowMinimizeButtonHint) text += "n| Qt::WindowMinimizeButtonHint"; if (flags & Qt::WindowMaximizeButtonHint) text += "n| Qt::WindowMaximizeButtonHint"; if (flags & Qt::WindowCloseButtonHint) text += "n| Qt::WindowCloseButtonHint"; if (flags & Qt::WindowContextHelpButtonHint) text += "n| Qt::WindowContextHelpButtonHint"; if (flags & Qt::WindowShadeButtonHint) text += "n| Qt::WindowShadeButtonHint"; if (flags & Qt::WindowStaysOnTopHint) text += "n| Qt::WindowStaysOnTopHint"; if (flags & Qt::CustomizeWindowHint) text += "n| Qt::CustomizeWindowHint"; if (flags & Qt::MSWindowsOwnDC) text += "n| Qt::MSWindowsOwnDC"; if (flags & Qt::WindowMinMaxButtonsHint) text += "n| Qt::WindowMinMaxButtonsHint"; if (flags & Qt::MacWindowToolBarButtonHint) text += "n| Qt::MacWindowToolBarButtonHint"; if (flags & Qt::BypassGraphicsProxyWidget) text += "n| Qt::BypassGraphicsProxyWidget"; if (flags & Qt::WindowStaysOnBottomHint) text += "n| Qt::WindowStaysOnBottomHint"; if (flags & Qt::WindowFullscreenButtonHint) text += "n| Qt::WindowFullscreenButtonHint"; if (flags & Qt::WindowOkButtonHint) text += "n| Qt::WindowOkButtonHint"; if (flags & Qt::WindowCancelButtonHint) text += "n| Qt::WindowCancelButtonHint"; if (flags & Qt::WindowTransparentForInput) text += "n| Qt::WindowTransparentForInput"; if (flags & Qt::WindowDoesNotAcceptFocus) text += "n| Qt::WindowDoesNotAcceptFocus"; if (flags & Qt::WindowOverridesSystemGestures) text += "n| Qt::WindowOverridesSystemGestures"; qDebug()<<text; }
设置 setWindowFlags(Qt::FramelessWindowHint)之前QDialog的windowFLags;
“Qt::Dialog
| Qt::WindowTitleHint
| Qt::WindowSystemMenuHint
| Qt::WindowCloseButtonHint
| Qt::WindowContextHelpButtonHint”
设置后
“Qt::Widget
| Qt::FramelessWindowHint”
可见它是把他当成了QWidget来处理的,所以这个地方会造成QDialog的Qt::ApplicationModal阻塞失效,并且也没有置顶了。
延伸资料:关于Qt如何保持子窗口显示在最上面的两种方式
最后
以上就是虚拟板凳最近收集整理的关于Qt5.4 QDialog窗体圆角时圆角透明背景是黑色的解决方法的全部内容,更多相关Qt5.4内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复