• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

kevincarlson/QmlBridgeForMaterialDesignIcons: A simple bridge for including the ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kevincarlson/QmlBridgeForMaterialDesignIcons

开源软件地址(OpenSource Url):

https://github.com/kevincarlson/QmlBridgeForMaterialDesignIcons

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

QmlBridgeForMaterialDesignIcons

This project provides a look up table for using the Material Design Icons font in Qt/QML projects. The font contains thousands of icons designed to match Android's native icon set, which should help make applications that target mobile devices feel more at home on that platform.

The look up table is released under the terms of the MIT license, in order to permit usage in commercial applications distributed through the various app stores. The complete licensing terms are included at the top of the Icon.js file. This repository contains a copy of the Material Design Icons web font, which is distributed under the terms of the Apache Software License, version 2.0.

Using The Icons in a QML Project

  1. Download the Material Design Icons font, available at https://materialdesignicons.com/
  2. Add the font file, and Icon.js from this project to the project's QRC file
  3. When initializing the application from C++, add the font to the font database, QFontDatabase::addApplicationFont(":/materialdesignicons-webfont.ttf");
  4. Import Icon.js in any QML file where icons will be referenced: import "Icon.js" as MdiFont
  5. Add the desired icon to any QML item that can display text
    • Set font.family to "Material Design Icons"
    • Set the text property to the desired property of MdiFont.Icon, e.g. MdiFont.Icon.mdiFileImage

For a more thorough step by step guide, as well as an explanation of the design process, see https://kevincarlson.codes/using-material-design-icons-with-qml/.

Example

A simple, reusable QML Icon Button may look like this:

import QtQuick 2.7

import QtQuick.Controls 2.0
import "Icon.js" as MdiFont

Button {
    implicitHeight: 48
    implicitWidth: 48
    font.pointSize: 24
    font.family: "Material Design Icons"
}

The control could be used as follows, for a simple formatting toolbar:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import "Icon.js" as MdiFont

ToolBar {
    height: 56
    RowLayout {
        IconButton {
            text: MdiFont.Icon.formatBold
            checkable: true
        }

        IconButton {
            text: MdiFont.Icon.formatItalic
            checkable: true
        }

        IconButton {
            text: MdiFont.Icon.formatUnderline
            checkable: true
        }
        
        Item {
            width: 8
        }

        IconButton {
            text: MdiFont.Icon.formatIndentDecrease
        }

        IconButton {
            text: MdiFont.Icon.formatIndentIncrease
        }
    }
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap