I'm trying to remove the default Windows titlebar from my Qt window (QT version 5.12.2 and using C++) while still keeping the window borders. I've more or less achieved this using the flag Qt::CustomizeWindowHint
. However, this changes the window borders to white lines instead of the default borders.
Example of how the borders look AFTER I've applied the Qt::CustomizeWindowHint
flag:
As you can see, these are not the normal Windows window borders.
How can I change/edit these boders (i.e. change their color) or how am I able to keep the default Windows window borders while removing the titlebar?
Here's a minimal reproducible example:
main.cpp:
int main(int argc, char* argv[]) {
QApplication application(argc, argv);
launcher mainWindow;
//debugChecks();
mainWindow.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::MSWindowsFixedSizeDialogHint);
mainWindow.setWindowTitle("Test");
mainWindow.show();
return application.exec();
}
launcher.h
#pragma once
#include <QtWidgets/QMainWindow>
#include <QMouseEvent>
#include <QPoint>
#include "ui_launcher.h"
class launcher : public QMainWindow {
Q_OBJECT
public:
launcher(QWidget* parent = Q_NULLPTR);
private:
Ui::launcherClass ui;
void mousePressEvent(QMouseEvent* eventVar);
void mouseMoveEvent(QMouseEvent* eventVar);
int mouseClickX = 0;
int mouseClickY = 0;
};
launcher.cpp
#include "launcher.h"
launcher::launcher(QWidget* parent) : QMainWindow(parent) {
ui.setupUi(this);
}
void launcher::mousePressEvent(QMouseEvent* eventVar) {
mouseClickX = eventVar->x();
mouseClickY = eventVar->y();
}
void launcher::mouseMoveEvent(QMouseEvent* eventVar) {
move(eventVar->globalX() - mouseClickX, eventVar->globalY() - mouseClickY);
}