
Originally Posted by
wysota
It won't work

A frameless window is ignored by the window manager. On the other hand the window manager is responsible for honouring (or not) the stays-on-top hint. You can try masking the border out using
QWidget::setMask().
I've got this code:
WidgetTest.pro
QT += core gui
TARGET = WidgetTest
TEMPLATE = app
SOURCES += main.cpp \
mywidget.cpp
HEADERS += \
mywidget.h
QT += core gui
TARGET = WidgetTest
TEMPLATE = app
SOURCES += main.cpp \
mywidget.cpp
HEADERS += \
mywidget.h
To copy to clipboard, switch view to plain text mode
mywidget.h
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
{
Q_OBJECT
public:
explicit MyWidget
(QWidget *parent
= 0);
~MyWidget();
};
#endif // MYWIDGET_H
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QWidget>
class MyWidget : public QWidget
{
Q_OBJECT
public:
explicit MyWidget(QWidget *parent = 0);
~MyWidget();
};
#endif // MYWIDGET_H
To copy to clipboard, switch view to plain text mode
mywidget.cpp
#include "mywidget.h"
{
setWindowFlags( Qt::FramelessWindowHint );
}
MyWidget::~MyWidget()
{
}
#include "mywidget.h"
MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
setWindowFlags( Qt::FramelessWindowHint );
}
MyWidget::~MyWidget()
{
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QtGui/QApplication>
#include "mywidget.h"
int main(int argc, char *argv[])
{
MyWidget myWidget;
myWidget.show();
return a.exec();
}
#include <QtGui/QApplication>
#include "mywidget.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget myWidget;
myWidget.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
And it pops up with a grey window with no border. How does that work?
Bookmarks