Qt移除标题b

2024-05-29 05:02:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个从QWidget继承的MediaPanel,我想隐藏标题栏,但是如果我用setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);(或其他类似的标志)设置标志,结果仍然是相同的:mediaPanel

如果我使用setWindowFlags(Qt::Window | Qt::FramelessWindowHint);,我将丢失所有的按钮、标签和滑块:empty media panel

我玩过Qt的例子,有些组合似乎是不可能的。。。

编辑:

我已经发布了一部分代码,有人能告诉我应该在哪里设置标志吗?

主.cpp:

#include <QApplication>
#include "JokerWindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    JokerWindow w(&settings);
    w.show();
    return a.exec();
}

小丑窗

#ifndef JOKERWINDOW_H
#define JOKERWINDOW_H

#include <QMainWindow>
#include "PhCommonUI/PhMediaPanelDialog.h"

namespace Ui {
class JokerWindow;
}

class JokerWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit JokerWindow(QSettings *settings);
    ~JokerWindow();

private:
    PhMediaPanelDialog _mediaPanel;
};
#endif // MAINWINDOW_H

JokerWindow.cpp

#include "JokerWindow.h"
#include "ui_JokerWindow.h"

JokerWindow::JokerWindow(QSettings *settings) :
    QMainWindow(NULL),
    ui(new Ui::JokerWindow)
{
    _mediaPanel.show();
}
JokerWindow::~JokerWindow()
{
    delete ui;
}

PhMediaPanel.h

#ifndef PHMEDIAPANEL_H
#define PHMEDIAPANEL_H

#include <QWidget>
namespace Ui {
    class PhMediaPanel;
}
class PhMediaPanel : public QWidget
{
    Q_OBJECT
public:
    explicit PhMediaPanel(QWidget *parent = 0);
    ~PhMediaPanel();
private:
    Ui::PhMediaPanel *ui;
};

#endif // PHMEDIAPANEL_H

PhMediaPanel.cpp

#include "PhMediaPanel.h"
#include "ui_PhMediaPanel.h"
PhMediaPanel::PhMediaPanel(QWidget *parent) :
    QWidget(parent)
{
    ui->setupUi(this);
}
PhMediaPanel::~PhMediaPanel()
{
    delete ui;
}

Tags: uisettingsinclude标志publicqtcppclass
1条回答
网友
1楼 · 发布于 2024-05-29 05:02:18

setWindowFlags(Qt::Window | Qt::FramelessWindowHint)对我有效。请确保将设置应用于最高级别的窗口。e、 g在main.cpp中看到下面的图片,原谅有线3D的事情,测试一些OpenGL代码。enter image description here

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  WoodPuppet window;

  window.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
  window.show();
}

相关问题 更多 >

    热门问题