Project

General

Profile

WTable click on selected rows

Added by Pedro Vicente over 1 year ago

I have a WTable and I want to respond on a lick on a given row

implementing the clicked() function applies to the all widget

is it possible to find which row was selected?

or do I have to implement a clicked() response for each row (and how? )

m_table_messages = box_right->addWidget(std::make_unique<Wt::WTable>());
m_table_messages->resize(1000, Wt::WLength::Auto);
m_table_messages->setStyleClass("table_messages");
m_table_messages->clicked().connect(this, &NostroApplication::table_show);


Replies (2)

RE: WTable click on selected rows - Added by Matthias Van Ceulebroeck over 1 year ago

Hi Pedro,

Here in the documentation you can see (in the inheritance graph) which classes inherit the clicked() signal.
If you want to have a signal for each row, you would need to place a widget for each row that has a clicked() signal. (e.g. WContainerWidget).

Alternatively, there is a WTableView, which can be used to select items from a model, and offers the selectionChanged() method.

RE: WTable click on selected rows - Added by Pedro Vicente over 1 year ago

Hi Matthias

thanks, this works

 Wt::WText* t = m_table_messages->elementAt(m_row, 0)->addNew<Wt::WText>(str);
    t->setStyleClass("col");
    t->clicked().connect([=]()
      {
        t->setText("Hello there");
      });

    (1-2/2)