Project

General

Profile

Bug #4233 ยป 4233.cpp

Benoit Daccache, 08/26/2015 10:12 AM

 
#include <Wt/WApplication>
#include <Wt/WPushButton>
#include <Wt/WContainerWidget>
#include <iostream>


#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WSortFilterProxyModel>
#include <Wt/WComboBox>

using namespace Wt;

class Test4233
: public Wt::WApplication {
public:
Test4233( const Wt::WEnvironment& env )
: Wt::WApplication( env )
{
WComboBox *box = new WComboBox();

WStandardItemModel *amodel = new WStandardItemModel();
int rows = 5;
int columns = 1;

Wt::WStandardItem *item = new Wt::WStandardItem("aaabbb");
amodel->setItem(0, 0, item);
item = new Wt::WStandardItem("cccddd");
amodel->setItem(1, 0, item);
item = new Wt::WStandardItem("eeefff");
amodel->setItem(2, 0, item);
item = new Wt::WStandardItem("ggghhh");
amodel->setItem(3, 0, item);
item = new Wt::WStandardItem("iiijjj");
amodel->setItem(4, 0, item);

WSortFilterProxyModel *model = new WSortFilterProxyModel();

model->setSourceModel(amodel);

model->setFilterRegExp("[a-e]+");

box->setModel(model);

root()->addWidget(box);

auto b = new WPushButton("Reset");

root()->addWidget(b);

b->clicked().connect(std::bind([ = ]() {
box->setCurrentIndex(-1);
}));
}

};

WApplication *createApplication(const WEnvironment& env)
{
return new Test4233(env);
}

int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
    (1-1/1)