setAutoFillBackground( true ); //这一句必需要,否则设置背景色失败
QPalette plt = palette();
plt.setColor(QPalette::Window,Qt::green);this->setPalette(plt);
本文介绍如何使用Qt为窗口设置绿色背景色。通过调用setAutoFillBackground(true)确保背景色生效,并利用QPalette自定义颜色。
setAutoFillBackground( true ); //这一句必需要,否则设置背景色失败
QPalette plt = palette();
plt.setColor(QPalette::Window,Qt::green);
3056
951
5509

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