Qml 目前版本的 ComboBox,不支持设置下拉菜单字体在一番搜索加调整后,完成下面的代码,可以满足这个功能。
如果想实现ComboBox带图片+字体,请见QML ComboBox 图片加文字
这是我搜索整理后的例子:

import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1Item {id: comboBoxwidth: 200height: 50z: 1property var model: ["One", "Two", "Three"]Button {id: comboButtonanchors.fill: parentcheckable: truetext : model[0]style: ButtonStyle {background: Rectangle {color: control.pressed ? "#888" : "#fff"smooth: trueradius: 5border.width: 2}label: Text {renderType: Text.NativeRenderingverticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenter
//                font.family: "Courier"
//                font.capitalization: Font.SmallCapsfont.pointSize: 30color: "black"text: comboButton.text}}onVisibleChanged: {if(!visible)checked = false}onCheckedChanged: listView.visible = checked}ListView {id: listViewheight :250width: comboButton.widthz: 3  // 保证在最顶,控件可见anchors.top: comboButton.bottomvisible: falsemodel: comboBox.modelhighlightFollowsCurrentItem: truehighlight: Rectangle { color: "lightsteelblue"; radius: 5 }delegate: Rectangle{id: delegateItemwidth: comboButton.widthheight: comboButton.height-0.5radius: 5color: ListView.isCurrentItem? "lightblue" : "#fee"Text {renderType: Text.NativeRenderinganchors.verticalCenter: parent.verticalCenteranchors.horizontalCenter: parent.horizontalCenter
//                    font.family: "Courier"
//                    font.capitalization: Font.SmallCapsfont.pointSize: 30color: "black"elide: Text.ElideMiddletext: modelData}MouseArea {anchors.fill: parent;onClicked: {listView.currentIndex = indexcomboButton.text = comboBox.model[listView.currentIndex]comboButton.checked = false}}}}
}

效果如下:

下面是google到的一个例子,但是在MacOS上不好用。

import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
import QtQuick.Controls.Private 1.0ComboBox {id: boxcurrentIndex: 2activeFocusOnPress: truestyle: ComboBoxStyle {id: comboBoxbackground: Rectangle {id: rectCategoryradius: 5border.width: 2color: "#fff"}label: Text {verticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenterfont.pointSize: 15font.family: "Courier"font.capitalization: Font.SmallCapscolor: "black"text: control.currentText}// drop-down customization hereproperty Component __dropDownStyle: MenuStyle {__maxPopupHeight: 600__menuItemType: "comboboxitem"frame: Rectangle {              // backgroundcolor: "#fff"border.width: 2radius: 5}itemDelegate.label:             // an item textText {verticalAlignment: Text.AlignVCenterhorizontalAlignment: Text.AlignHCenterfont.pointSize: 15font.family: "Courier"font.capitalization: Font.SmallCapscolor: styleData.selected ? "white" : "black"text: styleData.text}itemDelegate.background: Rectangle {  // selection of an itemradius: 2color: styleData.selected ? "darkGray" : "transparent"}__scrollerStyle: ScrollViewStyle { }}property Component __popupStyle: Style {property int __maxPopupHeight: 400property int submenuOverlap: 0property Component frame: Rectangle {width: (parent ? parent.contentWidth : 0)height: (parent ? parent.contentHeight : 0) + 2border.color: "black"property real maxHeight: 500property int margin: 1}property Component menuItemPanel: Text {text: "NOT IMPLEMENTED"color: "red"font {pixelSize: 14bold: true}}property Component __scrollerStyle: null}}model: ListModel {id: cbItemsListElement { text: "Banana" }ListElement { text: "Apple" }ListElement { text: "Coconut" }}width: 200

效果如下:

参考:
Access Listview currentIndex from Delegate
QML ListView currentItem doesn’t change after a sort

ComboxBox 调整字体相关推荐

  1. android 调整字体,android设置:调整字体大小

    在手机的设置中,我可以全局更改应用的字体大小.android设置:调整字体大小 设置>显示>字体大小 我可以做的字体大小(小,中,大,非常大),也看过Java和(如果适用).只为我的应用程 ...

  2. 禁用微信 webview 调整字体大小

    微信 webview 内置了调整字体大小的功能,对于网页的可用性来说是一个很实用的功能.一些网页的字体设置过小导致用户看不清文字,调整字体大小即可解决这个问题. 但是对于一些追求显示效果的移动端页面来 ...

  3. Eclipse如何调整字体大小

    Eclipse如何调整字体大小 1.Eclipse字体大小调整: 2.Eclipse xml和jsp文件字体大小调整: 两者我都设置如下: 1.Eclipse字体大小调整: 窗口(Window)-首选 ...

  4. android textView调整字体的间距和行间距

    今天,就随便写的textView的内容. 字间距 textView有一个属性android:textScaleX是调节字间距的,它的值是一个float型.查看源代码,默认textView 此属性是使用 ...

  5. IDEA如何设置鼠标滚轮调整字体大小

    IDEA如何设置鼠标滚轮调整字体大小 之前介绍过IDEA的字体设置IDEA字体调整,但这样修改起来太麻烦,IDEA可以支持快捷键快速修改字体的大小(神器吧~),我们来看一下如何配置: 打开Settin ...

  6. 禁止微信内置浏览器调整字体大小

    微信webview内置了调整字体大小的功能,用户可以根据实际情况进行调节.但是很多移动端页面的开发都是使用rem作为单位的,字体大小改变以后,会出现页面布局错乱的情况,因此希望能够禁止微信的字体放大功 ...

  7. 新版火狐浏览器怎么调整字体 火狐浏览器字体调整技巧分享

    相信有了解的朋友都清楚,官方在新版火狐浏览器中不仅优化了UI设计,还带来了一些细微的变化与改进.那么,新版火狐浏览器该怎么调整字体呢?下面小编就来分享一下火狐浏览器字体调整技巧,有需要的朋友可以稍作参 ...

  8. 手机web禁止微信调整字体

    we微信浏览器缩放以及分享靠的都是是微信浏览器WeixinJSBridge接口,android禁止微信浏览器调整字体大小代码如下: <script type="text/javascr ...

  9. 解决微信调整字体大小导致Html5页面混乱

    原理:阻止ios和安卓调整字体大小时候的事件,ios通过添加css属性,安卓通过微信属性去阻止 注:添加后无法通过外部更改字体大小,根据项目需求运用 ios系统: body{-webkit-text- ...

最新文章

  1. 并发-9-Callable和Future
  2. CentOS7.2 安装Docker
  3. uwp选取文件夹并读取其中的图片
  4. 计算机动画专业要学什么课程,计算机动画制作专业主要课程有哪些?
  5. class会不会回收?用不到的class怎么回收_5分钟!用Java实现目标检测 | PyTorch
  6. emif接口速率问题_OMAPL138 EMIF读取速率问题
  7. Struts 2 的Action详解(三)
  8. Python实践周 A卷 试题(不印刷)
  9. LNMP环境部署----之Mysql安装部署
  10. [转]VC6.0编译fltk-1.1.10
  11. java毕向东学习笔记——day09
  12. 【ts】有关报错Line 0: Parsing error: Cannot read property ‘map‘ of undefined的解决方法
  13. Pyton爬虫编程入门学习笔记(八)学习正则表达式
  14. 直接渲染管理器(Direct Rendering Manager, DRM)
  15. vue3.0父传子,父传孙,子传孙,孙传父,孙传子的传值
  16. Python 医学知识图谱问答系统(一),建立医学知识图谱,基于neo4j知识图谱的医学问答体系
  17. 蓝牙【GATT】协议介绍
  18. 【Java应用】使用Java实现机器学习算法:聚类、分类、预测
  19. 欧拉角(Euler angles)
  20. 我整理了一些Python测试的库,看一下有没有你需要的库

热门文章

  1. 飞思卡尔Kinetis 60(K60)时钟系统分析
  2. 树莓派4B arm平台aarch64 pip安装pytorch
  3. 如何获取如何获取datagrid复选框的值_火影忍者博人传木叶丸获取方法详解 博人传木叶丸如何获取...
  4. 如何把“蚂蚁呀嘿”换脸特效用在前端 WebRTC 视频通话中
  5. ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
  6. Firfox flash player
  7. 小白也能看懂的网络基础 | 02 什么是连接设备?
  8. 【HTML】HTLM网页设计----我的家乡网页设计,根据不同家乡更换名称,图片
  9. 手写字体识别 --MNIST数据集
  10. Git详解之六 Git工具