Design a window without a caption bar - QT Designer

前端 未结 2 825
醉话见心
醉话见心 2021-01-13 02:46

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

2条回答
  •  情歌与酒
    2021-01-13 03:13

    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

提交回复
热议问题