22

I've a MediaPanel which inherits from QWidget and I want to hide the title bar but event if I set the flags with setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint); (or some other flags like ) the result is still the same : mediaPanel

and if I use setWindowFlags(Qt::Window | Qt::FramelessWindowHint); I lose all the buttons, labels and sliders : empty media panel

I've played with the Qt example and some combination seems to be impossible...

EDIT :

I've posted a reduced part of my code, could someone tell me where should I set the flags ?

main.cpp :

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

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

JokerWindow.h

#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;
}
8
  • Have you tried: setWindowFlags(getWindowFlags() | Qt::FramelessWindowHint); Commented Nov 29, 2013 at 17:49
  • Also make sure you do that to the top level window! Commented Nov 29, 2013 at 17:52
  • @hyde What do you mean by top level? The one on top? The first level Parent? The last level child? Commented Nov 29, 2013 at 18:01
  • I mean the widget without parent, IOW NULL parent. Commented Nov 29, 2013 at 18:19
  • @hyde it is not the main widget so it had a parent. I try to use this->setParent(NULL) but it didn't change the problem Commented Nov 29, 2013 at 18:28

3 Answers 3

46

setWindowFlags(Qt::Window | Qt::FramelessWindowHint) works for me. Make sure you are applying the setting on your highest level window. e.g in the main.cpp See the image below, forgive the wired 3D thing, testing some OpenGL code. enter image description here

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

  window.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
  window.show();
}
Sign up to request clarification or add additional context in comments.

5 Comments

Take a look at my result when setting flags to Qt::Window | Qt::FramelessWindowHint
hyde mentioned the same thing. I used exactly the same function you used "setWindowFlags(Qt::Window | Qt::FramelessWindowHint)" on my very top window. In the main function, see the edit in my post.
Ah, I got you, you have another windows for displaying the video?. where do you initialize this control panel. I think you put the setWindowFlags(Qt::Window | Qt::FramelessWindowHint) on one of your inner widget. I attempted to do the setWindowFlags(Qt::Window | Qt::FramelessWindowHint) on my OpenGL widget, it will disappear as well. If you can post some code of your initialize process, it may help.
What kind of object is your WoodPuppet ? A QWindow or a QWidget ?
If anyone is looking for the same answer but in PyQt5, it's your_widget.setWindowFlag(QtCore.Qt.FramelessWindowHint, True).
0

This is what I did with qPysie6. I just directly use flags property in QML.

import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
    id: root
    visible: true
    width: 400; height: 300
    title: "Windows"
    flags: Qt.FramelessWindowHint
}

QWindow Class

Comments

0

For PyQT just do:

your_widget.setWindowFlags(Qt.Window | Qt.FramelessWindowHint)

And it works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.