Design a window without a caption bar - QT Designer

孤者浪人 提交于 2019-12-19 08:28:25

问题


How can I declare a window without caption when I use QT Designer?


回答1:


if you're looking to remove window title, then the easiest way would be to set the window flags in your widget's constructor, smth like this:

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent, Qt::FramelessWindowHint),  //<-- this will remove the title bar
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
... 

or call

Qt::WindowFlags flags = Qt::CustomizeWindowHint;
setWindowFlags(flags);

more details on window types here: enum Qt::WindowType flags Qt::WindowFlags

hope this helps, regards




回答2:


you didn't say which language you mean, so I say how to do it in Python with Qt : First of all, you can't-do it in Qt Designer application!

After you designed your GUI via Qt designer app, then you should add this line of python code to your FILE.py (generated with pyuic5) :

MainWindow.setWindowFlags(QtCore.Qt.CustomizeWindowHint)



来源:https://stackoverflow.com/questions/4799748/design-a-window-without-a-caption-bar-qt-designer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!