Qt4.5 QFrame(相當於Delphi里的TPanel,有各種凹凸方式)


QFrame類是有框架的窗口部件的基類。

QPopupMenu使用這個來把菜單“升高”,高於周圍屏幕。QProgressBar有“凹陷”的外觀。QLabel有平坦的外觀。這些有框架的窗口部件可以被改變。

 

QLabel label(...);
 label.setFrameStyle(QFrame::Panel | QFrame::Raised);
 label.setLineWidth(2);
 
 QProgressBar pbar(...);
 label.setFrameStyle(QFrame::NoFrame);

 

 

QFrame類也可以直接被用作創建一個簡單的框架,而沒有任何內容。

 

框架類型可以通過 frame shape 和 shadow style 這兩個屬性來指定,以區別其他控件;

這些屬性可以通過setFrameStyle()來一起設置,frameStyle()函數讀取

 

1、frame shape包括: NoFrame, Box, Panel, StyledPanel, HLine ,VLine;

enum QFrame::Shape

Constant

Value

Description

QFrame::NoFrame

0

QFrame draws nothing不畫任何

QFrame::Box

0x0001

QFrame draws a box around its contents內容四周有框

QFrame::Panel

0x0002

QFrame draws a panel to make the contents appear raised or sunken有平台使內容看起來凹起或下沉

QFrame::StyledPanel

0x0006

draws a rectangular panel with a look that depends on the current GUI style. It can be raised or sunken.

依據當前GUI類型,畫一個矩形面板,可以凹起或下沉

QFrame::HLine

0x0004

QFrame draws a horizontal line that frames nothing (useful as separator)畫一個沒有框架的水平線(用作分隔符)

QFrame::VLine

0x0005

QFrame draws a vertical line that frames nothing (useful as separator) 畫一個沒有框架的垂直線(用作分隔符)

QFrame::WinPanel

0x0003

draws a rectangular panel that can be raised or sunken like those in Windows 95. Specifying this shape sets the line width to 2 pixels. WinPanel is provided for compatibility. For GUI style independence we recommend using StyledPanel instead.

畫類似win95的矩形面板,指定形狀線寬2象素。

 

 

2shadow styles 包括 Plain Raised Sunken.

 

3、一個框架控件有三個屬性,描述邊框的寬度:lineWidth,midLineWidth,frameWidth

 

線寬就是框架邊界的寬度

中間線寬指定的是在框架中間的另外一條線的寬度,它使用第三種顏色來得到一個三維的效果。注意中間線只有在BoxHLineVLine這些凸起和凹陷的框架中才被繪制。

框架寬度決定於框架類型,frameWidth()函數根據當前使用的style類型獲得值

 

http://blog.csdn.net/mociml/article/details/5086007


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM