初學qt,邊看書邊自己做點小東西。最近突然心血來潮,想自己做個小巧點的,介面美觀一點的備忘當桌面上。想了半天,發現vista/win7的aero效果就不錯,況且自己現在就在用win7。於是上網找了下qt製作aero效果的方法。google之後終於找到了函式和用法。於是做了乙個簡單的aero特效視窗
以下是標頭檔案和實現檔案:
#ifndef qtwin_h
#define qtwin_h
#include
#include
class windownotifier;
class qtwin
; #endif // qtwin_h
#include "qtwin.h"
#include
#include
#include
#include
#ifdef q_ws_win
#include
// blur behind data structures
#define dwm_bb_enable 0x00000001 // fenable has been specified
#define dwm_bb_blurregion 0x00000002 // hrgnblur has been specified
#define dwm_bb_transitiononmaximized 0x00000004 // ftransitiononmaximized has been specified
#define wm_dwmcompositionchanged 0x031e // composition changed window message
typedef struct _dwm_blurbehind
dwm_blurbehind, *pdwm_blurbehind;
typedef struct _margins
margins, *pmargins;
typedef hresult (winapi *ptrdwmiscompositionenabled)(bool* pfenabled);
typedef hresult (winapi *ptrdwmextendframeintoclientarea)(hwnd hwnd, const margins* pmarinset);
typedef hresult (winapi *ptrdwmenableaerowindow)(hwnd hwnd, const dwm_blurbehind* pblurbehind);
typedef hresult (winapi *ptrdwmgetcolorizationcolor)(dword *pcrcolorization, bool *pfopaqueblend);
static ptrdwmiscompositionenabled pdwmiscompositionenabled= 0;
static ptrdwmenableaerowindow pdwmenableaerowindow = 0;
static ptrdwmextendframeintoclientarea pdwmextendframeintoclientarea = 0;
static ptrdwmgetcolorizationcolor pdwmgetcolorizationcolor = 0;
/* *同步響應dwm狀態訊息
*/
class windownotifier : public qwidget
void removewidget(qwidget *widget)
bool winevent(msg *message, long *result);
private:
qwidgetlist widgets;
};
static bool resolvelibs()
return pdwmiscompositionenabled != 0;
} #endif
/*!
* 檢查 dwm 是否開啟
* */
bool qtwin::iscompositionenabled()
#endif
return false;
} /*!
* 對乙個widget實現aero效果.
* */
bool qtwin::enableaerowindow(qwidget *widget, bool enable)
; hresult hr = s_ok;
bb.fenable = enable;
bb.dwflags = dwm_bb_enable;
bb.hrgnblur = null;
widget->setattribute(qt::wa_translucentbackground, enable);
widget->setattribute(qt::wa_nosystembackground, enable);
hr = pdwmenableaerowindow(widget->winid(), &bb);
if (succeeded(hr))
} #endif
return result;
} /*!
* 設定aero繪圖區
*/
bool qtwin::extendframeintoclientarea(qwidget *widget, int left, int top, int right, int bottom)
; hr = pdwmextendframeintoclientarea(widget->winid(), &m);
if (succeeded(hr))
widget->setattribute(qt::wa_translucentbackground, result);
} #endif
return result;
} /*!
* 返回當前視窗顏色.
*/
qcolor qtwin::colorizatincolor()
#endif
return resultcolor;
} #ifdef q_ws_win
windownotifier *qtwin::windownotifier()
/* 所有視窗響應 dwm 狀態變換訊息 */
bool windownotifier::winevent(msg *message, long *result)
widget->update();
} }
return qwidget::winevent(message, result);
} #endif
使用的時候只需要在生成視窗的main.cpp中#include "qtwin.h",並使用相關函式,以下是main.cpp檔案:
#include "widget.h"
#include "qtwin.h"
int main(int argc, char *argv)
window.show();
return a.exec();
}
from:
QT 製作視窗圓角
一 設定視窗屬性 setwindowflags qt framelesswindowhint qt windowsystemmenuhint qt windowminmaxbuttonshint setattribute qt wa translucentbackground 二 使用qss新增圓角...
字幕特效製作
英文本型 n 1080p字幕 style cn,微軟雅黑,22,h00c0c0c0,h000000ff,h00000000,h00000000,1,0,0,0,80,100,3,0,1,2,2,2,10,10,2,1 style en,微軟雅黑,14,h0080ff,h000000ff,h00000...
WIN7旗艦版,AERO特效開啟
1,開啟條件 系統條件 vista高階版,vista商業版,vista終極版,win7旗艦版 備註 vista家庭版,win7家庭版的同學們,就不要浪費時間了 你們的系統不支援這個aero效果.趕緊重做系統去吧 2,開啟方法 1 右擊 我的電腦 選擇 屬性 高階系統設定 高階效能 設定,選中 調整為...