該視窗自定義標題欄,視窗可移動,可伸縮,使用的是系統自帶陰影邊框
1 標題欄相關**
#pragma once
#include
class
uititlebar
:public qwidget
;
#include
"stdafx.h"
#include
"uititlebar.h"
uititlebar::
uititlebar
(qwidget *parent)
:qwidget
(parent)
uititlebar::
~uititlebar()
void uititlebar::
initui()
void uititlebar::
updatemaximize()
}void uititlebar::
on_btn_clicked()
else
if(_btn == m_btnmax)
else
if(_btn == m_btnclose)
>
quit()
;}}void uititlebar::
mousepressevent
(qmouseevent* event)
void uititlebar::
mousemoveevent
(qmouseevent* event)}if
(m_ispressed)
}return qwidget::
mousemoveevent
(event);}
void uititlebar::
mousereleaseevent
(qmouseevent* event)
void uititlebar::
mousedoubleclickevent
(qmouseevent* event)
2 客戶區相關**#pragma once
#include
class
uicontentwnd
:public qwidget
void
setimage
(const qpixmap& _pixmap)
;private
: qpixmap m_pixmapbk;};
```cpp
#include
"stdafx.h"
#include
"uicontentwnd.h"
uicontentwnd::
uicontentwnd
(qwidget *parent)
:qwidget
(parent)
uicontentwnd::
~uicontentwnd()
void uicontentwnd::
setimage
(const qpixmap& _pixmap)
void uicontentwnd::
paintevent
(qpaintevent* ev)
}
3 主視窗相關**#pragma once
#include
class
uimainwnd
:public qmainwindow
;
#include
"stdafx.h"
#include
"uimainwnd.h"
#include
"uititlebar.h"
#include
"uicontentwnd.h"
uimainwnd::
uimainwnd
(qwidget *parent)
:qmainwindow
(parent)
uimainwnd::
~uimainwnd()
void uimainwnd::
initui()
4 標題欄相關樣式uititlebar qlabel#logolabel
/*關閉*/
uititlebar qpushbutton#closebutton
uititlebar qpushbutton#closebutton:hover
uititlebar qpushbutton#closebutton:pressed
/*最大化*/
uititlebar qpushbutton#maxbutton
uititlebar qpushbutton#maxbutton:hover
uititlebar qpushbutton#maxbutton:pressed
uititlebar qpushbutton#maxbutton[maximizeproperty="maximize"]
uititlebar qpushbutton#maxbutton[maximizeproperty="maximize"]:hover
uititlebar qpushbutton#maxbutton[maximizeproperty="maximize"]:pressed
uititlebar qpushbutton#maxbutton[maximizeproperty="restore"]
uititlebar qpushbutton#maxbutton[maximizeproperty="restore"]:hover
uititlebar qpushbutton#maxbutton[maximizeproperty="restore"]:pressed
/*最小化*/
uititlebar qpushbutton#minbutton
uititlebar qpushbutton#minbutton:hover
uititlebar qpushbutton#minbutton:pressed
android自定義標題欄
1.建立自定義標題欄的xml檔案,可以給標題欄加背景 引用或者在drawable檔案下通過xml檔案生成 2.在activity中通過requestwindowfeature window.feature custom title 宣告使用自定義標題 3.setcontentview r.layou...
android自定義標題欄
用自定義控制項的方法建立上面的標題欄,順便重溫一下自定義控制項的步驟。下面說一下整個過程 1.在layout下新增標題欄布局檔案來設定標題欄樣式 2.在values資料夾下建立attrs.xml檔案 這個檔案主要用來定義自定義控制項的屬性和格式,格式有 reference,float,color,d...
自定義JFrame JDialog標題欄
最近一直在做flex,晚上看看世界盃,一些比賽真的很沒勁 so,就想寫寫swing,想起以前有人問過如何替換jframe或者jdialog的標題欄,就動手寫了寫 提供了titleframe和titledialog兩個頂層元件,主要功能 1 自定義標題欄 2 可以通過滑鼠拖拽調整元件大小 可關閉res...