如何在 QComboBox 的 addItem 中下标字符串 [英] How to subscript string in QComboBox's addItem

查看:39
本文介绍了如何在 QComboBox 的 addItem 中下标字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 addItem 将化学式输入到 QComboBox,但我不知道如何为数字添加下标.我真的很感激我能得到的任何帮助.

I am trying to enter a chemical formula using addItem to a QComboBox, but I do not know how to subscript the numbers. I would really appreciate any help I can receive.

我试过:1.在数字$\3$"前后使用美元符号($)2. 使用大括号和美元符号$_{3}$"3.使用Unicode格式\u2083".这个有效,但当您看到下拉菜单的选项时,它只显示子脚本编号.选择该选项后,它将显示一个竖线代替数字(见图)

I have tried: 1. Using dollar signs ($) before and after the number "$\3$" 2. Using curly brackets and dollar signs "$_{3}$" 3. Using Unicode formatting "\u2083". This one works but it only shows the sub scripted number when you see the options of the drop down menu. After you select the option, it'll display a vertical bar in place of the number (see pics)

self.amp_sub1_Box = QtGui.QComboBox(self)
self.amp_sub1_Box.addItem("H")
self.amp_sub1_Box.addItem("CH\u2083")
self.amp_sub1_Box.addItem("CH\u2082CH\u2083")

推荐答案

正如 ekhumoro 在评论中所建议的,改变字体样式解决了这个问题.只需使用:QComboBox.setFont(QtGui.QFont('Verdana'))

As ekhumoro suggested in the comments, changing the font style solved this problem. Just use: QComboBox.setFont(QtGui.QFont('Verdana'))

这篇关于如何在 QComboBox 的 addItem 中下标字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆