Project

General

Profile

Bug #11380 ยป tableview_check.cpp

Roel Standaert, 02/28/2023 04:44 PM

 
#include <Wt/WApplication.h>
#include <Wt/WBootstrap2Theme.h>
#include <Wt/WBootstrap3Theme.h>
#include <Wt/WBootstrap5Theme.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WEnvironment.h>
#include <Wt/WStandardItem.h>
#include <Wt/WStandardItemModel.h>
#include <Wt/WTableView.h>

#include <memory>

class Application final : public Wt::WApplication {
public:
explicit Application(const Wt::WEnvironment& env);
};

Application::Application(const Wt::WEnvironment &env)
: Wt::WApplication(env)
{
const auto themePtr = env.getParameter("theme");
if (themePtr) {
if (*themePtr == "bootstrap2") {
auto theme = std::make_shared<Wt::WBootstrap2Theme>();
theme->setResponsive(true);
setTheme(theme);
} else if (*themePtr == "bootstrap3") {
auto theme = std::make_shared<Wt::WBootstrap3Theme>();
theme->setResponsive(true);
setTheme(theme);
} else if (*themePtr == "bootstrap5") {
setTheme(std::make_shared<Wt::WBootstrap5Theme>());
} else {
setCssTheme(*themePtr);
}
} else {
setTheme(std::make_shared<Wt::WBootstrap5Theme>());
}

auto model = std::make_shared<Wt::WStandardItemModel>(0, 1);

for (int i = 0; i < 10; ++i) {
auto item = std::make_unique<Wt::WStandardItem>(Wt::utf8("Item {1}").arg(i));
item->setCheckable(true);
model->appendRow(std::move(item));
}

auto table = root()->addNew<Wt::WTableView>();
table->resize(200, 400);
table->setRowHeight(32);

table->setModel(model);
}

int main(int argc, char *argv[])
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
return std::make_unique<Application>(env);
});
}
    (1-1/1)