当前位置:网站首页>Qframe class learning notes
Qframe class learning notes
2022-07-29 05:41:00 【cloud_ yq】
QFrame Class study notes
Reference resources :https://wenku.baidu.com/view/759c1af565ce050877321322.html
https://doc.qt.io/qt-5/qframe.html
1、QFrame The role of
QFrame Class inherited from QWidget class , By QAbstractScrollArea, QLabel, QLCDNumber, QSplitter, QStackedWidget, and QToolBox Equal class inheritance . QFrame As the base class of many basic controls , Provide many member methods to subclasses , Implement the design of the framework style of subclasses . The frame style mainly consists of the frame shape and the shadow style used to visually separate the frame from the surrounding widgets . namely
(1)QFrame Provides design framework style member functions for subclasses , Help subclass design unique style : Or the border protrudes 、 Or the frame is sunken 、 Or the content protrudes 、 Or content depression and other effects .
(2)QFrame It can also be used directly to create a simple placeholder frame without any content .
2、QFrame Member type document
2.1 enum QFrame::Shadow
This enumeration type defines the type used to provide 3D The shadow type of the effect .
QFrame::Plain 0x0010 The border or content looks as high as the surrounding controls
QFrame::Raised 0x0020 The border or content looks more prominent than the surrounding controls
QFrame::Sunken 0x0030 The border or content looks sunken than the surrounding controls
2.2 enum QFrame::Shape
This enum Type defines the shape of the available frames .
QFrame::NoFrame 0 Don't draw anything
QFrame::Box 0x0001 Draw a border to wrap the content , Highlight the shadow effect of the border
QFrame::Panel 0x0002 Draw a content plane , Highlight the shadow effect of the content
QFrame::StyledPanel 0x0006 Drawing a look depends on the current GUI Style rectangular panel . It can be raised or depressed .
QFrame::HLine 0x0004 Draw a horizontal line , Act as a separator , Highlight the shadow effect of the line
QFrame::VLine 0x0005 Draw a vertical line , Act as a separator , Highlight the shadow effect of the line
QFrame::WinPanel 0x0003 Draw a rectangular panel , Can be like Windows 2000 Move up or down like that . Specifies that this shape sets the lineweight to 2 Pixels .WinPanel It is provided for compatibility . Yes On GUI Style independence , We recommend using StyledPanel Instead of .
2.3 enum QFrame::StyleMask
This enumeration defines two constants , It can be used to extract frameStyle() Two components of .
QFrame::Shadow_Mask 0x00f0 The control of framStyle() The return value of shadow part
QFrame::Shape_Mask 0x000f The control of framStyle() The return value of shape part
2.4 Use QFrame Realizable style combinations

3、QFrame Common member functions
3.1 Introduction to member function prototype
| Member function prototype | describe |
| QFrame(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) | Construction and destructor |
| virtual ~QFrame() | |
| QRect frameRect() const | obtain / Set up QFrame Frame size |
| void setFrameRect(const QRect &) | |
| QFrame::Shadow frameShadow() const | obtain / Set up Shadow style , |
| void setFrameShadow(QFrame::Shadow) | |
| QFrame::Shape frameShape() const | obtain / Set up Shape of frame |
| void setFrameShape(QFrame::Shape) | |
| int frameStyle() const | obtain / Set up The shape and shadow style of the frame |
| void setFrameStyle(int style) | |
| int lineWidth() const | obtain / Set up Width of frame line |
| void setLineWidth(int) | |
| int midLineWidth() const | obtain / Set up The width of the center line of the frame |
| void setMidLineWidth(int) |
3.2 A simple example
Use QFrame Subclasses of QLabel Complete the design of simple login interface , Through to QLabel The change of frame style makes it more consistent QLineEdit、QPushButton And other control styles .
//.h file
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
private:
QLabel *useLabel;
QLabel *pwLabel;
QLabel *useEdit;
QLabel *pwEdit;
QLabel *checkBtn;
QLabel *cancelBtn;
};
//.c file
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->resize(400,550);
useLabel = new QLabel(this);
useLabel->setText(" user name :");
useLabel->move(70,150);
useLabel->resize(50,30);
// Set up " user name " The frame style of the label is no border + No shadow
useLabel->setFrameShape(QFrame::NoFrame);
useLabel->setFrameShadow(QFrame::Plain);
useEdit = new QLabel(this);
useEdit->move(150,150);
useEdit->resize(200,30);
// Set up " user name " The frame style of the input box is Frame + protuberance
useEdit->setFrameStyle(QFrame::Box|QFrame::Raised);
useEdit->setLineWidth(2);
pwLabel = new QLabel(this);
pwLabel->setText(" password :");
pwLabel->move(70,210);
pwLabel->resize(50,30);
// Set up " password " The frame style of the label is no border + No shadow
pwLabel->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
pwEdit = new QLabel(this);
pwEdit->move(150,210);
pwEdit->resize(200,30);
// Set up " user name " The frame style of the input box is Content + Sunken
pwEdit->setFrameStyle(QFrame::Panel|QFrame::Sunken);
pwEdit->setLineWidth(2);
checkBtn = new QLabel(this);
checkBtn->setText(" confirm ");
checkBtn->setAlignment(Qt::AlignCenter);
checkBtn->move(100,290);
checkBtn->resize(80,30);
// Set up " confirm " The frame style of the button is Content + protuberance
checkBtn->setFrameStyle(QFrame::Panel|QFrame::Raised);
checkBtn->setLineWidth(3);
cancelBtn = new QLabel(this);
cancelBtn->setText(" Cancel ");
cancelBtn->setAlignment(Qt::AlignCenter);
cancelBtn->move(240,290);
cancelBtn->resize(80,30);
// Set up " Cancel " The frame style of the button is Content + protuberance
cancelBtn->setFrameStyle(QFrame::Panel|QFrame::Raised);
cancelBtn->setLineWidth(3);
}
design sketch :

边栏推荐
- 弹性盒子相关知识
- ClickHouse学习(八)物化视图
- Fvuln-自动化web漏洞检测工具
- link与@import的关系
- Clickhouse learning (x) monitoring operation indicators
- How does the MD editor of CSDN input superscripts and subscripts? The input method of formula and non formula is different
- Basic concepts of MySQL + database system structure + extended application + basic command learning
- Question swiping Madness - leetcode's sword finger offer58 - ii Detailed explanation of left rotation string
- Clickhouse learning (VII) table query optimization
- 常见特征工程操作
猜你喜欢

公众号不支持markdown格式文件编写怎么办?

Liang Yuqi, founder of aitalk: the link between image and virtual reality

Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration

Do students in the science class really understand the future career planning?

记xx公司SQL注入漏洞

ClickHouse学习(五)集群操作
![[C language series] - constants and variables that confuse students](/img/24/1158034a5de413ea4ce160c5bfcbb4.png)
[C language series] - constants and variables that confuse students

Hcia-r & s self use notes (26) PPP
![[JS question solution] questions 1-10 in JS of niuke.com](/img/9d/4bae4a9a048e4e5412f157ec632c94.png)
[JS question solution] questions 1-10 in JS of niuke.com

ClickHouse学习(八)物化视图
随机推荐
Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
HCIA-R&S自用笔记(26)PPP
全局components组件注册
微信小程序视频上传组件直接上传至阿里云OSS
Clickhouse learning (VIII) materialized view
【无标题】
移动端-flex项目属性
相对定位和绝对定位
VIM editor use
重绘与回流的关系
表格与表单相关知识点总结
[untitled]
On Paradigm
ANSI C type qualifier
Terminal shell common commands
Relationship between redrawing and reflow
用threejs 技术做游戏跑酷
Clickhouse learning (IX) Clickhouse integrating MySQL
C language n queen problem
Clickhouse learning (IV) SQL operation