QStyleFactory Class

QStyleFactory 类创建QStyle 对象。更多

头文件: #include <QStyleFactory>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets

静态公共成员

QStyle *create(const QString &key)
QStringList keys()

详细说明

QStyle 类是一个抽象基类,它封装了图形用户界面的外观和感觉。QStyleFactory 使用create() 函数和一个标识样式的键创建QStyle 对象。样式要么是内置的,要么是从样式插件动态加载的(参见QStylePlugin )。

可以使用keys() 函数检索有效的键。通常包括 "windows "和 "fusion"。根据平台的不同,"windowsvista "和 "macos "也可能可用。请注意,键值不区分大小写。

另请参阅 QStyle

成员函数文档

[static] QStyle *QStyleFactory::create(const QString &key)

创建并返回一个与给定的key 匹配的QStyle 对象,如果没有找到匹配的样式,则返回nullptr

内置样式和来自样式插件的样式都可以查询到匹配的样式。

注意: 使用的键不区分大小写。

另请参见 keys().

[static] QStringList QStyleFactory::keys()

返回有效键的列表,即该工厂可以创建样式的键。

另请参见 create()。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.