|
#include <Wt/WApplication.h>
|
|
#include <Wt/WContainerWidget.h>
|
|
#include <Wt/WCssStyleSheet.h>
|
|
#include <Wt/WServer.h>
|
|
#include <Wt/WStandardItem.h>
|
|
#include <Wt/WStandardItemModel.h>
|
|
#include <Wt/WTableView.h>
|
|
#include <Wt/WVBoxLayout.h>
|
|
|
|
#include <memory>
|
|
|
|
#define USE_LAYOUT 0
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) {
|
|
auto app = std::make_unique<Wt::WApplication>(env);
|
|
auto root = app->root();
|
|
|
|
auto model = std::make_shared<Wt::WStandardItemModel>(1000, 20);
|
|
for (int r = 0; r < model->rowCount(); ++r) {
|
|
for (int c = 0; c < model->columnCount(); ++c) {
|
|
model->setData(r, c, Wt::utf8("Row {1}, col {2}").arg(r).arg(c));
|
|
}
|
|
}
|
|
|
|
auto table = std::make_unique<Wt::WTableView>();
|
|
table->setModel(model);
|
|
|
|
#if USE_LAYOUT
|
|
auto layout = root->setLayout(std::make_unique<Wt::WVBoxLayout>());
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->addWidget(std::move(table));
|
|
#else
|
|
table->addStyleClass("mytable");
|
|
|
|
app->styleSheet().addRule(".mytable", Wt::utf8("width: 100vw; height: 100vh;"));
|
|
app->styleSheet().addRule("body", Wt::utf8("margin: 0;"));
|
|
|
|
root->addWidget(std::move(table));
|
|
#endif
|
|
|
|
return app;
|
|
});
|
|
}
|