Making a borderless window with for Qt
If your looking for some advanced styling in the shape of a widget, maybe this example will help you:
Shaped Clock Example
Or maybe you're simply looking for this kind of flag: Qt::CustomizeWindowHint
or simply Qt::FramelessWindowHint
.
How to create a draggable (borderless and titleless) top level window in QT
You'll find the answer to the first part in: Making a borderless window with for Qt, and the answer to the second part in Select & moving Qwidget in the screen.
Combining the two, and adding the last part is straightforward.
Here's how you could do it:
#include <QtGui>
class W: public QWidget
{
Q_OBJECT
Set up a borderless widget with a few buttons to lock/unlock and quit:
public:
W(QWidget *parent=0)
: QWidget(parent, Qt::FramelessWindowHint), locked(false)
{
QPushButton *lock = new QPushButton("Lock");
QPushButton *unlock = new QPushButton("Unlock");
QPushButton *quit = new QPushButton("&Quit");
connect(lock, SIGNAL(clicked()), this, SLOT(lock()));
connect(unlock, SIGNAL(clicked()), this, SLOT(unlock()));
connect(quit, SIGNAL(clicked()),
QApplication::instance(), SLOT(quit()));
QHBoxLayout *l = new QHBoxLayout;
l->addWidget(lock);
l->addWidget(unlock);
l->addWidget(quit);
setLayout(l);
}
public slots:
void lock() {
locked = true;
move(x(), 0); // move window to the top of the screen
}
void unlock() { locked = false; }
Do the mouse handling:
protected:
void mousePressEvent(QMouseEvent *evt)
{
oldPos = evt->globalPos();
}
void mouseMoveEvent(QMouseEvent *evt)
{
const QPoint delta = evt->globalPos() - oldPos;
if (locked)
// if locked, ignore delta on y axis, stay at the top
move(x()+delta.x(), y());
else
move(x()+delta.x(), y()+delta.y());
oldPos = evt->globalPos();
}
private:
bool locked;
QPoint oldPos;
};
Borderless window in Qt on Windows which supports native features: aero snap, DWM resize and minimization
I've found a workaround for this problem.
Instead of using Qt main window, i've created a simple WinAPI borderless window, like in this SO discussion. Then i added QWinWidget from QtWinMigrate project, and filled window with it.
As result, main window and resizable edges are handled by WinAPI, and everything inside main window is handled by QWinWidget. And with QWinWidget you can create Qt gui like in any other Qt app.
Here is a small example project on GitHub.
Aero Snap with Borderless Window in Qt
I was looking for this kind of Qt window and I have finally found a solution.
This GitHub example does the job like a charm (thanks to deimos1877)!
https://github.com/deimos1877/BorderlessWindow
Be sure to use visual studio compiler to get the needed DLL and it should work.
This example include aerosnap support, borderless window, minimize effect, aero shadows.
How to make QML window borderless?
It seems like impossible to set properties for Rectangle tag to make a borderless frame.
The only solution below is applicable (use 'setFlags' method):
//qml viewer
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/agritrade/main.qml"));
viewer.setFlags(Qt::Window|Qt::FramelessWindowHint);
viewer.showExpanded();
QT QMainWindow fullscreen without borders
You want to setWindowFlags
, with Qt::FramelessWindowHint
and Qt::CustomizeWindowHint
. So mainWindow->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint)
should work for you.
Related Topics
What Is the Ndebug Preprocessor MACro Used for (On Different Platforms)
Why Does Valgrind Say Basic Sdl Program Is Leaking Memory
How to Produce Deterministic Binary Output with G++
Why the Libc++ Std::Vector Internally Keeps Three Pointers Instead of One Pointer and Two Sizes
Address of Function Is Not Actual Code Address
Visual Studio 2017 Can't Find Windows.H
Read Word by Word from File in C++
C++ Template Metaprogramming - How to Output the Generated Code
How to Find a Particular Value in an Array and Return Its Index
Why Is Rvo Disallowed When Returning a Parameter
How to Print Member Function Address in C++
Returning Non-Const Reference from a Const Member Function
Does Throw Inside a Catch Ellipsis (...) Rethrow the Original Error in C++
Std::Remove_Const with Const References
How to Create a C++ Boost Undirected Graph and Traverse It in Depth First Search (Dfs) Order