Project

General

Profile

WTable that leaves WContainerWidget area

Added by Pedro Vicente over 3 years ago

Good morning

I have an application that displays a WTable and WText widgets.

WText are organized in a WVBoxLayout

When I display the page , the WTable "gets out" of the container widget, as shown in the image,
column 5 does now show up
(table in green leaves the yellow container section)

Is there a way to avoid this?
thanks

code

`
Application_messages::Application_messages(const Wt::WEnvironment& env) :
WApplication(env)
{
useStyleSheet("boxes.css");

auto container = std::make_uniqueWt::WContainerWidget();
container->setStyleClass("yellow-box");
auto hbox = container->setLayout(std::make_uniqueWt::WHBoxLayout());
auto vbox_comm = hbox->addLayout(std::make_uniqueWt::WVBoxLayout());

const Wt::WBorder border(Wt::WBorder::Style::Solid, 1);
auto table = std::make_uniqueWt::WTable();
table->setStyleClass("green-box");
table->setHeaderCount(1);

table->elementAt(0, 0)->addNewWt::WText("col1");
table->elementAt(0, 1)->addNewWt::WText("col2");
table->elementAt(0, 2)->addNewWt::WText("col3");
table->elementAt(0, 3)->addNewWt::WText("col4");
table->elementAt(0, 4)->addNewWt::WText("col5");

std::string s("123456789012345678");
for (size_t idx_row = 0; idx_row < 5; idx_row++)
{
size_t idx = idx_row + 1;
table->elementAt(idx, 0)->addNewWt::WText(s);
table->elementAt(idx, 1)->addNewWt::WText(s);
table->elementAt(idx, 2)->addNewWt::WText(s);
table->elementAt(idx, 3)->addNewWt::WText(s);
table->elementAt(idx, 4)->addNewWt::WText(s);
}

for (int i = 0; i < table->rowCount(); ++i)
{
for (int j = 0; j < table->columnCount(); ++j)
{
table->elementAt(i, j)->decorationStyle().setBorder(border);
}
}

std::unique_ptrWt::WText text1 = std::make_uniqueWt::WText("item 1");
text1->setStyleClass("blue-box");
text1->setWidth(400);
vbox_comm->addWidget(std::move(text1));

std::unique_ptrWt::WText text2 = std::make_uniqueWt::WText("item 2");
text2->setStyleClass("blue-box");
text2->setWidth(400);
vbox_comm->addWidget(std::move(text2));

hbox->addWidget(std::move(table), 1);
root()->addWidget(std::move(container));
}
`