Project

General

Profile

Bug #6260 ยป Example.cpp

Markus S, 02/28/2018 11:43 AM

 
#include <Wt/WApplication>
#include <Wt/WTreeView>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>

namespace
{
class TestTreeView
: public Wt::WApplication
{
public:
TestTreeView( const Wt::WEnvironment& env )
: Wt::WApplication( env )
{
Wt::WTreeView* treeView = new Wt::WTreeView( root() );

Wt::WStandardItemModel* model = new Wt::WStandardItemModel( 0, 1, treeView );
model->setHeaderData( 0, Wt::Horizontal, std::string( "Click here reconnects events every time" ) );

std::vector< Wt::WStandardItem* > items;
items.push_back( new Wt::WStandardItem( "Click to test how often the mouse events fire" ) );
model->appendRow( items );
treeView->setModel( model );
treeView->clicked().connect
( []( auto model, ... )
{
static int count = 0;
std::cout << "clicked " << count++ << " - Valid = " << model.isValid() << std::endl;
});
}
};
}
    (1-1/1)