'Removing titlebar from Qt window while keeping the default window borders

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: enter image description here

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);
}



Solution 1:[1]

QPalette and QStyle for Border

Palette Can Change window styles and colors of the Application. and for Reference https://doc.qt.io/archives/qt-5.7/qtwidgets-widgets-styles-example.html

Solution 2:[2]

You can do something like this

self.setWindowTitle("?") # Python

?

mainWindow.setWindowTitle(""); # C/C++

but instead of passing an empty string, pass an empty character. This one worked for me: https://emptycharacter.com/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tamil
Solution 2 Martí Climent