方法一:
setAutoFillBackground(true);
方法二:
不要传this指针给子窗口。
dialog dlg(this);
dlg.exec();
改为
dialog dlg;
dlg.exec();
本文介绍了两种在Qt中实现窗口背景自动填充的方法。第一种方法是通过调用setAutoFillBackground(true)来启用自动填充功能;第二种方法则是避免将父窗口指针传递给子窗口,从而防止继承导致的背景显示问题。
方法一:
setAutoFillBackground(true);
方法二:
不要传this指针给子窗口。
dialog dlg(this);
dlg.exec();
改为
dialog dlg;
dlg.exec();

被折叠的 条评论
为什么被折叠?