利用QML实现透明窗口[qt5]
来源:互联网 发布:python swf反编译 编辑:程序博客网 时间:2024/05/22 17:04
<p>mainwindow.h</p>
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QDeclarativeView>class MainWindow: public QDeclarativeView{ Q_OBJECTpublic: MainWindow(QWidget * p=0); ~MainWindow();};#endif
mainwindow.cpp
#include "mainwindow.h"MainWindow::MainWindow(QWidget *p) :QDeclarativeView(p){ // transparent background this->setAttribute(Qt::WA_TranslucentBackground); this->setStyleSheet("background: transparent;"); // no window decorations setWindowFlags(Qt::FramelessWindowHint); // set QML setSource(QUrl("main.qml"));}MainWindow::~MainWindow(){}
main.pro
QT += core gui widgets declarative TARGET = mainTEMPLATE = appSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.hOTHER_FILES += main.qml
main.qml
import QtQuick 1.0Rectangle{ id: root width: 250 height: 250 // // completely transparent background color: "#00FFFFFF" border.color: "#F00" border.width: 2 Rectangle{ id: ball height: 50 width: 50 x: 100 color: "#990000FF" radius: height / 2 } SequentialAnimation{ running: true loops: Animation.Infinite NumberAnimation{ target: ball; property: "y"; to: root.height-ball.height; duration:1000 easing.type: Easing.OutBounce } PauseAnimation{ duration: 1000} NumberAnimation { target: ball; property: "y"; to: 0; duration: 700 } PauseAnimation { duration: 1000 } }}
main.cpp
//ref: http://stackoverflow.com/questions/7613125/how-to-make-a-transparent-window-with-qt-quick//#include <QtGui/QApplication>#include <QApplication>#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}
qt5 下编译不通过:How to make a transparent window with Qt Quick?
0 0
- 利用QML实现透明窗口[qt5]
- qml实现窗口拖动
- gtk+实现透明窗口
- 如何实现透明窗口
- MFC实现透明窗口
- 实现窗口透明
- 透明窗口的实现
- java实现窗口透明
- wxPython 窗口实现透明
- VC实现透明窗口
- QML之窗口(无边框、透明及拖拽)
- QML之窗口(无边框、透明及拖拽)
- 关于Qt5 使用QQuickWidget加载QML背景设置透明的问题!
- VC如何实现透明窗口
- VC如何实现透明窗口
- 用SetLayeredWindowAttributes实现窗口透明
- 局部透明窗口的实现
- Qt实现背景窗口透明
- Matlab2012 下载与安装
- Tomcat中JVM内存溢出及合理配置
- MARK UP
- QML 文本无法显示问题
- Javascript的V8引擎之所以快
- 利用QML实现透明窗口[qt5]
- LeetCode-Roman to Integer
- LeetCode-Integer to Roman
- ubuntu防火墙关闭命令
- hadoop错误Name node is in safe mode的解决方法
- Hashtable
- first unique character in a string
- Permutation Sequence
- Codeforces 467D. Fedor and Essay (Graphs,dfs,dp,hashing,strings,图论综合型好题)