Qt 代码风格之:类名,函数名,变量名

目录

========================

类名:QWidget,首 1个、或2个字母(Q开头)大写;后续的其他单词的首字母大写。“首字母”

QWidget,   QKeySequence,  Qt::ShortcutContext

Qt 普通函数名:首字母小写;后续的其他单词的首字母大写;末尾部分有函数标志的括号。有“括号”

grabShortcut()

Qt 特别函数名

使用下划线“_”

void MainWindow::on_pushButton_clicked()

变量名:首字母小写;后续的其他单词的首字母大写;末尾部分没有括号。无“括号”

QSizePolicy::Policy vertical

结论:

1. 直接通过“首字母”,以及“括号”,就可以区分出类名,函数名,变量名。

2. Qt 特别函数名:使用下划线“_”。

    普通变量:没有下划线“_”。

    宏名:可有下划线“_”。

3. 拓展:????????

mode_abcDefGhe() //函数  void MainWindow::on_pushButton_clicked()

mode_AbcDefGhe //变量

Mode_AbcDefGhe //类

Mode_abcDefGhe //待定??

通过首字母:区分,类名 与 函数名和变量名。

通过“括号”:区分,函数名 与 变量名。


 

注意:

1. C++ 驼峰风格:可以表达更多的区分

2. 与过去的C语言风格,有区别:

C函数风格: 使用下划线“_”

void abc_def_ghe()

官方例子:

QMetaClassInfo QMetaObject::classInfo(int index) const

int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut)

void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)

初步观察:

1. Qt 函数名,变量名:均没有下划线“_”。

2. 有下划线“_”:宏名,以及其他非函数名或变量名的场景。

Qt 5.14
All Functions

Qt 5.14.2 Reference Documentation

All Functions
This is the list of all documented member functions and global functions in the Qt API. Each function has a link to the class or header file where it is declared and documented.
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
DECLARE_READING: global QSensorReading
DTDHandler: QXmlReader QXmlSimpleReader


Qt 5.14
All Classes

Qt 5.14.2 Reference Documentation

All Classes
This is a list of all Qt 5 classes. The following pages contain different API listings in different categories:
All Functions
All Namespaces
All Classes by Module
Obsolete Classes
New Classes and Functions in Qt 5.14
For more reference pages including QML types, visit Qt Reference Pages.
A B C D E F G H I J K L M N O P Q R S T U V W X
3
Q3DBars
Q3DCamera
Q3DInputHandler
Q3DLight
Q3DObject
Q3DScatter

====================

宏:采用函数型外观

QAXFACTORY_BEGIN(IDTypeLib, IDApp)

This macro can be used to export multiple QObject classes through an implicitly declared QAxFactory implementation. All QObject classes have to declare the ClassID, InterfaceID and EventsID (if applicable) through the Q_CLASSINFO() macro. All declarations will be in a type library with the id IDTypeLib, and if the server is an executable server then it will have the application id IDApp.

QSG_DECLARE_SIMPLE_COMPARABLE_SHADER(Shader, State)

This macro is used to declare a QSGMaterialType and a createMaterial() function for Shader with the given State, where the State class must define a compare function on the form:

Qt::Key_PageUp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值