Advertisement
Guest User

main.cpp - WTableViewBug

a guest
Apr 17th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <Wt/WApplication>
  2. #include <Wt/WContainerWidget>
  3. #include <Wt/WText>
  4. #include <Wt/WTableView>
  5. #include <Wt/WTimer>
  6. #include <Wt/WTabWidget>
  7. #include <Wt/WStringListModel>
  8.  
  9. #include <boost/bind.hpp>
  10.  
  11. using namespace Wt;
  12.  
  13. namespace {
  14.    void timerFired(WStringListModel * model)
  15.    {
  16.          model->addString("A");
  17.          model->addString("B");
  18.          model->addString("C");
  19.          model->addString("D");
  20.          model->addString("E");
  21.          model->addString("F");
  22.          model->addString("G");
  23.          model->addString("H");
  24.          model->addString("I");
  25.          model->addString("J");
  26.          model->addString("K");
  27.          model->addString("L");
  28.          model->addString("M");
  29.          model->addString("N");
  30.          model->addString("O");
  31.          model->addString("P");
  32.    }
  33. }
  34.  
  35. class MyApp : public WApplication {
  36.    public:
  37.       MyApp(const WEnvironment& env)
  38.       : WApplication(env)
  39.       {
  40.          //Just for looks
  41.          WCssTextRule *styleRule = new WCssTextRule(".test", "background:#FEE;");
  42.          styleSheet().addRule(styleRule);
  43.  
  44.          WContainerWidget * cont = new WContainerWidget(root());
  45.          cont->setStyleClass("test");
  46.  
  47.          //Make the tableview
  48.          WTableView * table = new WTableView(root());
  49.          WStringListModel * model = new WStringListModel( table );
  50.          table->setModel( model );
  51.  
  52.          //Setup a timer to update the model
  53.          WTimer::singleShot( 2000, boost::bind(&timerFired, model) );
  54.  
  55.          cont->addWidget(table);
  56.       }
  57.  
  58.       static Wt::WApplication* CreateApplication (const Wt::WEnvironment& env)
  59.       {
  60.          return new MyApp(env);
  61.       }
  62. };
  63.  
  64. int main (int argc, char** argv)
  65. {
  66.    return WRun(argc, argv, &MyApp::CreateApplication);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement