16,211
社区成员
发帖
与我相关
我的任务
分享
setAttribute(Qt::WA_TranslucentBackground,true);
setWindowFlags(Qt::WindowStaysOnTopHint);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground,true);
setWindowFlags(Qt::FramelessWindowHint);
setWindowFlags(Qt::WindowStaysOnTopHint);
#include <QtGui>
class Widget : public QWidget {
public:
Widget() : QWidget() {
setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground,true);
//QPalette pal = palette();
//pal.setColor(QPalette::Background, QColor (0, 0 , 0, 20));
//setPalette(pal);
}
protected:
void paintEvent(QPaintEvent *pe) {
QPainter p(this);
p.setBrush(Qt::red);
p.setRenderHint(QPainter::Antialiasing);
p.drawEllipse(rect().adjusted(50,50,-50,-50));
}
void resizeEvent(QResizeEvent *re) {
setMask(rect());
}
};
int main(int argc, char **argv) {
QApplication app(argc, argv);
Widget w;
w.show();
return app.exec();
}