#include #include #include #include #include #include #include #include #include #include using namespace Wt; // ----------------------------------------------------------------------------------- std::unique_ptr buildTableViewTab() { int rows = 6; int columns = 10; std::shared_ptr model = std::make_shared(rows, columns); for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { auto item = std::make_unique(); item->setText("Item " + std::to_string(row) + ", " + std::to_string(column)); model->setItem(row, column, std::move(item)); } } auto listCont = std::make_unique(); auto listVLayout = listCont->setLayout(std::make_unique()); listVLayout->setContentsMargins(0, 0, 0, 35); listVLayout->setSpacing(2); auto demoTable = listVLayout->addWidget(std::make_unique(), 1); demoTable->setAlternatingRowColors(true); demoTable->setSelectionMode(SelectionMode::Single); demoTable->setColumnResizeEnabled(true); demoTable->setModel(model); listVLayout->addWidget(std::make_unique("Lower Line")); return listCont; } // ----------------------------------------------------------------------------------- std::unique_ptr createHelloApplication(const WEnvironment &env) { auto app = std::make_unique(env); auto theme = std::make_shared(); theme->setVersion(Wt::BootstrapVersion::v3); app->setTheme(theme); WVBoxLayout *mainLayout = app->root()->setLayout(std::make_unique()); // this will work, when WTabWidget part below is commented out // mainLayout->addWidget(buildTableViewTab(), 1); auto tabWidget = mainLayout->addWidget(std::make_unique(), 1); tabWidget->addTab(buildTableViewTab(), "WTableView Problem"); tabWidget->addTab(std::make_unique("Demo Content"), "Demo Empty"); return app; } // ----------------------------------------------------------------------------------- int main(int argc, char *argv[]) { try { WServer server(argc, argv, WTHTTP_CONFIGURATION); server.addEntryPoint(EntryPointType::Application, std::bind(&createHelloApplication, std::placeholders::_1)); if (server.start()) { int sig = WServer::waitForShutdown(); std::cerr << "*** Shutdown (signal = " << sig << ")" << std::endl; server.stop(); if (sig == 1) // SIGHUP WServer::restart(argc, argv, environ); return 0; } } catch (WServer::Exception &e) { std::cerr << "*** Server Exception: " << e.what() << std::endl; } catch (std::exception &e) { std::cerr << "*** Std Exception: " << e.what() << std::endl; } }