StupidBeauty
Read times:304Posted at:Sun Dec 4 01:50:34 2011
- no title specified

Wt3.1.11文档翻译:Wt::WSelectionBox类参考,Wt::WSelectionBox Class Reference

详细描述

选择框允许用户从一個选项列表中进行选择。

默认情况下,选择框允许用户从列表中选择一個条目。可以使用setSelectionMode()来改成多选模式。

SingleSelection(单选)模式,可使用setCurrentIndex()currentIndex()来设置及读取当前选中项。在Wt::ExtendedSelection(扩展选择)模式,可使用setSelectedIndexes()selectedIndexes()来设置及读取当前选中项。在Wt::ExtendedSelection模式下不会发射activated()sactivated()信号,这种情况下妳需要监听changed()信号。

WSelectionBox是一個MVC(模型视图控制器)视图类,默认情况下使用一個简单的字符串列表模型。这個模型可使用WComboBox::addItem()WComboBox::insertItem()来填充(populated),其内容可使用clear()来清除。这些方法会对底层的模型(model())进行操作。

要使用一個自定义的模型来替换选择框的默认模型WStringListModel的话,则使用setModel()

使用示例:

Wt::WSelectionBox *selectionBox = new Wt::WSelectionBox(this);

selectionBox->addItem("Clint Eastwood");

selectionBox->addItem("Mick Jagger");

selectionBox->addItem("Johnny Depp");

selectionBox->addItem("Kate Winslet");

selectionBox->setCurrentIndex(2); // Johnny Depp

selectionBox->activated().connect(this, &MyWidget::comboChanged);

WSelectionBox是一個内联(inline )部件。

CSS

这個部件对应于HTML <select>标记,不提供样式设置。它可使用内联或外部样式单来进行样式设置。

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4