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 :
and if I use setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
I lose all the buttons, labels and sliders :
I've played with the Qt example and some combination seems to be impossible...
I've posted a reduced part of my code, could someone tell me where should I set the flags ?
#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
#include "JokerWindow.h"
#include "ui_JokerWindow.h"
JokerWindow::JokerWindow(QSettings *settings) :
QMainWindow(NULL),
ui(new Ui::JokerWindow)
{
_mediaPanel.show();
}
JokerWindow::~JokerWindow()
{
delete ui;
}
#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
#include "PhMediaPanel.h"
#include "ui_PhMediaPanel.h"
PhMediaPanel::PhMediaPanel(QWidget *parent) :
QWidget(parent)
{
ui->setupUi(this);
}
PhMediaPanel::~PhMediaPanel()
{
delete ui;
}
To remove the frame of any window using Qt you need to use the following piece of code: setWindowFlags(Qt::Window | Qt::FramelessWindowHint); Note that this will also cause the title bar of the window to be removed which means there will be no “close”, “minimize” and “maximize” buttons.
In order to hide the label we use setHidden() method, this method allows user to set if the widget should be visible or hidden, it belongs to the QWidget class .
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.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
WoodPuppet window;
window.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
window.show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With