Project

General

Profile

Bug #2036 ยป HeaderCrash.cpp

Koen Deforche, 09/20/2013 04:46 PM

 
#include <Wt/WApplication>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WContainerWidget>
#include <Wt/WTableView>

using namespace Wt;

int cols = 3;
int rows = 10;

class TestApp : public WApplication
{
public:
void createRow(std::vector<WStandardItem *>& row, int size,
const std::string& s) {

row.clear();

for (int i = 0; i < size; ++i) {
WStandardItem *t
= new WStandardItem(s + " c" + boost::lexical_cast<std::string>(i));

row.push_back(t);
}
}

WStandardItemModel *createModel() {
WStandardItemModel *model_ = new WStandardItemModel(0, cols, this);

for (int i = 0; i < cols; ++i)
model_->setHeaderData(i, Horizontal,
"col " + boost::lexical_cast<std::string>(i));

std::vector<WStandardItem *> row;

for (unsigned i = 0; i < rows; ++i) {
createRow(row, cols, "Item "+ boost::lexical_cast<std::string>(i));
model_->appendRow(row);
}

return model_;
}

TestApp(const WEnvironment& env) : WApplication(env)
{
WTableView *tv = new WTableView(root());
tv->decorationStyle().setBorder(WBorder(WBorder::Solid, 1, black));
tv->setHeight(500);
tv->setModel(createModel());

for (int i = 0; i < tv->model()->columnCount(); ++i)
tv->hideColumn(i);
}

void foo() {
}

private:
};

WApplication *createApplication(const WEnvironment& env)
{
TestApp *app = new TestApp(env);

return app;
}

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