Project

General

Profile

Bug #811 ยป hello.C

reproducible with this example - Pieter Libin, 05/05/2011 05:16 PM

 
/*
* Copyright (C) 2008 Emweb bvba, Heverlee, Belgium.
*
* See the LICENSE file for terms of use.
*/

#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WTableView>

using namespace Wt;

class HelloApplication : public WApplication
{
public:
HelloApplication(const WEnvironment& env);
};

HelloApplication::HelloApplication(const WEnvironment& env)
: WApplication(env)
{
int rows = 2;
int columns = 3;
WStandardItemModel *model = new WStandardItemModel(rows, columns, this);

for (int row = 0; row < rows; ++row) {
for (int column = 0; column < columns; ++column) {
WStandardItem *item = new WStandardItem();
item->setText("Item " + boost::lexical_cast<std::string>(row)
+ ", " + boost::lexical_cast<std::string>(column));
model->setItem(row, column, item);
}
}

WTableView* table = new WTableView(root());
table->setModel(model);
table->setAlternatingRowColors(true);
table->setSelectionMode(SingleSelection);

table->resize(770, 40); //CRASH

table->setDragEnabled(false);
table->setLineHeight(20);
table->setColumnWidth(0, 596);
table->setColumnWidth(1, 160);
table->setColumnAlignment(1, AlignRight);
}

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

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

    (1-1/1)