I am trying to implement a frameless window in Qt 5.2 C++.
This answer -would- be perfect for me, but that no longer works in Qt5 - Borderless window in Qt on Windows which supports native features: aero snap, DWM resize and minimization
What I've done is created a basic MainWindow widget, set the properties via stylesheet, and it's almost what I want except for a few things.
This code:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent, Qt::CustomizeWindowHint ), ui(new Ui::MainWindow)
{
ui->setupUi(this);
//this->setFixedSize(300, 450);
this->statusBar()->setSizeGripEnabled(true);
this->setStyleSheet("background-color: white; border: 1px solid red;");
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
}
Will give me -almost- what I want, main problems being -
- There is some odd bar at the top, which looks like this. When I right click on the bar, then left click the checkbox, it dissappears. How do I disable this by default? (Please excuse the 3rd party links, StackOverflow does not allow newcomers to host pics here)
http://i57.tinypic.com/2iapqnn.png
- As seen, only the side borders are 1 px, and the top/bottom borders are more like 4 px. There is also that odd bar at the bottom (similar to the one at the top, before it gets removed) that I'd like removed. How do I disable the bottom bar, and make sure ALL borders are exactly 1 px wide?
http://i62.tinypic.com/28qsnrk.png
All I want is an empty white, resizeable window with 1 px red borders.
Thank you very much for your help. Have a great day.