ComboBox控件介绍(有用啊)

10 篇文章 1 订阅

ComboBox控件

1.控件位置

Input Widgets→ComboBox

2.控件介绍

ComboBox控件(组合框)的样式如图3-63所示。Qt Creator的ComboBox和Qt Designer的ComboBox样式有些不同。

 
图3-63 ComboBox控件

3.控件设置选项

在ComboBox控件的properties选项中,一般常对以下选项进行设置。

name:该控件对应源代码中的名称;

font:设置显示的字体;

editable:用来获取或设置一个值,以确定ComboBox的编辑框是否可编辑。值为true时为可编辑,值为false时为只读;

currentIndex:当前选项的索引;

maxVisibleItems:ComboBox可见的最大项目数;

maxCount:ComboBox的最大项目数。

4.常用成员函数

 
 
  1. 1) QComboBox::QComboBox ( QWidget *parent = 0, const char *name = 0 ) 

构造一个名称为name、父对象为parent的ComboBox。
 
 
  1. 2) QComboBox::QComboBox ( bool rw, QWidget *parent = 0, const char *name = 0 ) 

构造一个名称为name、父对象为parent的ComboBox。如果rw是true,则编辑栏可编辑;否则只能选择ComboBox项目之一。
 
 
  1. 3) void QComboBox::clear () [slot] 

删除ComboBox中的所有项目。
 
 
  1. 4) int QComboBox::count () const 

返回ComboBox中的项目数。
 
 
  1. 5) int QComboBox::currentItem () const 

返回ComboBox中当前项目的索引。
 
 
  1. 6) QString QComboBox::currentText () const 

返回组合框的当前项目文本。
 
 
  1. 7) void QComboBox::insertItem ( const QString & t, int index = -1 ) 

在索引index处,插入一个文本为t的项目。如果index是负数,该项目将被追加到末尾。
 
 
  1. 8) void QComboBox::insertItem ( const QPixmap & pixmap, int index = -1 ) 

在索引index处,插入一个图标为pixmap的项目。如果index是负数,该项目将被追加到末尾。
 
 
  1. 9) void QComboBox::insertItem ( const QPixmap & pixmap, const QString & text, int index = -1 ) 

在索引index处,插入一个文本为t和图标为pixmap的项目。如果index是负数,该项目将被追加到末尾。
 
 
  1. 10) QString QComboBox::currentText () const 

返回组合框的当前项目文本。
 
 
  1. 11) void QComboBox::removeItem ( int index ) 

删除索引index处项目。
 
 
  1. 12) void QComboBox::setCurrentItem ( int index ) [virtual] 

把索引index处的项目设为当前项目。
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值