Qt remove title bar
c++, qt, window
Solution
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();
}
Problem
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... 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; } ```