当前位置:网站首页>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 :
边栏推荐
- VIM editor use
- 无重复字符的最长字串
- Detailed installation and use tutorial of MySQL (nanny installation with pictures and texts)
- [typescript] learn typescript object types in depth
- Wapiti是什么以及使用教程
- Seay源代码审计系统
- 弹性盒子相关知识
- [C language series] - string + partial escape character explanation + annotation tips
- 第三课threejs全景预览房间案例
- redis的基本使用
猜你喜欢
[C language series] - storage of deep anatomical data in memory (I) opening of summer vacation
Clickhouse learning (XI) clickhouseapi operation
B - identify floating point constant problems
eggjs 创建应用知识点
【TypeScript】TypeScript中类型缩小(含类型保护)与类型谓词
ClickHouse学习(五)集群操作
Database operation day 6
table中同一列中合并相同项
[sword finger offer] - explain the library function ATOI and simulate the realization of ATOI function
[JS question solution] questions 1-10 in JS of niuke.com
随机推荐
【TypeScript】深入学习TypeScript对象类型
ClickHouse学习(六)语法优化
Topological ordering of a graph of water
2022 mathematical modeling competition summer training lecture - optimization method: goal planning
[C language series] - print prime numbers between 100 and 200
Basic principle of recursion
Thrift安装手册
HCIA-R&S自用笔记(27)综合实验
Wechat applet - screen height
Set the background color of a cell in the table
href与src的区别
Relationship between link and @import
用threejs 技术做游戏跑酷
Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect
Clickhouse learning (x) monitoring operation indicators
Relative positioning and absolute positioning
Day 1
记xx公司SQL注入漏洞
Application of Huffman tree and Huffman coding in file compression
Redirection and files