StupidBeauty
Read times:304Posted at:Tue Jul 5 00:15:29 2011
- no title specified

Wt3.1.9文档翻译:Wt::WAggregateProxyModel类参考,Wt::WAggregateProxyModel Class Reference

详细描述

针对Wt 的条目模型的一个代理模型,它提供列的聚合。

这个代理模型本身并不储存数据,而是呈现来自于一个源模型的数据 ,并且提供一些用来通过聚合来组织列的方法 ,用户可在那些列中导航 (通常是为咯获取与一个聚合量相关的更多详细信息)。

要使用勒个代理模型的话,你应当使用 setSourceModel() 来提供一个源模型 ,再使用 addAggregate() 来定义一个可 被聚合的列范围。

示例

int COLS = 18;

int ROWS = 20;

//设置源模型

model_ = new WStandardItemModel(0, COLS);

std::string columns[] = {

"Supplier",

"2004",

"Q1",

"January",

"February",

"March",

"Q2",

"April",

"May",

"June",

"Q3",

"July",

"August",

"September",

"Q4",

"October",

"November",

"December"

};

for (unsigned i = 0; i < COLS; ++i) {

model_->setHeaderData(i, Horizontal, columns[i]);

}

for (unsigned i = 0; i < ROWS; ++i) {

model_->insertRow(i);

for (unsigned j = 0; j < COLS; ++j)

model_->setData(i, j, "col " + boost::lexical_cast<std::string>(j));

}

//设置代理模型

WAggregateProxyModel *proxy = new WAggregateProxyModel();

proxy->setSourceModel(model_);

proxy->addAggregate(1, 2, 17);

proxy->addAggregate(2, 3, 5);

proxy->addAggregate(6, 7, 9);

proxy->addAggregate(10, 11, 13);

proxy->addAggregate(14, 15, 17);

proxy->expandColumn(1); //展开2004 -> Q1 Q2 Q3 Q4

//定义一个视图

treeView_ = new WTreeView(root());

treeView_->setColumnBorder(Wt::black);

treeView_->setModel(proxy);

treeView_->setColumnWidth(0, 160);

treeView_->setColumnResizeEnabled(true);

treeView_->setSortingEnabled(true);

这个示例显示出来之后的样子:

使用WAggregateProxyModel的一个 WTreeView

注意

这个模型不支持动态修改源模型的列定义(也就是说 ,插入或删除源模型的列 )。

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