Qt Mainwindow添加/删除标题栏

需求:添加/删除Qt Mainwindow的标题栏

特殊点:不能在Mainwindow外部进行设置,须在Mainwindow内部设置(SLOT或其他内部函数中)

传统方法:

this->setWindowFlags(Qt::FramelessWindowHint);                //取消标题栏

this->setWindowFlags(windowFlags()&~Qt::FramelessWindowHint); //增加标题栏

问题描述:Mainwindow会闪退

解决方法:

this->setWindowFlags(Qt::FramelessWindowHint);                //取消标题栏

show();

this->setWindowFlags(windowFlags()&~Qt::FramelessWindowHint); //增加标题栏

show();

分别增加show()函数即可。



猜你喜欢

转载自blog.csdn.net/qq_34329383/article/details/80506853