Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 1.09 KB

File metadata and controls

37 lines (23 loc) · 1.09 KB

QComboBox

1、下拉数据关联

运行 CityLinkage.py

一个省市区关联的三级联动,数据源在data.json中

  1. 主要用了QComboBoxsetModel设置一个QSortFilterProxyModel过滤模型
  2. 并根据唯一编码过滤,为了不影响内容显示,唯一编码的角色为ToolTipRole
  3. QColumnView可以实现类似效果

CityLinkage

2、文本居中显示

运行 CenterText.py

  1. 使用QProxyStyle对文件居中显示
  2. 新增得item数据使用setTextAlignment对齐

CenterText

2、样式美化

运行 ComboBoxStyle.py

  1. 使用setView使得QComboBox的下拉窗口支持样式
  2. 通过setAttributesetWindowFlags设置下拉窗口的属性,支持透明和无边框
  3. 样式中通过qlineargradient设置 | 的渐变效果,让两端透明

ComboBoxStyle