mardi 29 décembre 2020

Wt++ TableView and QueryModel

I have a problem with tableView and queryModel this is my error:

    lo.C: In constructor ‘HelloApplication::HelloApplication(const Wt::WEnvironment&)’:
hello.C:162:48: error: no matching function for call to ‘Wt::WTableView::setModel(std::remove_reference<Wt::Dbo::QueryModel<Wt::Dbo::ptr<Utente> >*&>::type)’
 tableView->setModel( std::move(modelDataTable) );
                                                ^
In file included from hello.C:30:0:
/usr/local/include/Wt/WTableView.h:94:16: note: candidate: virtual void Wt::WTableView::setModel(const std::shared_ptr<Wt::WAbstractItemModel>&)
   virtual void setModel(const std::shared_ptr<WAbstractItemModel>& model)
                ^
/usr/local/include/Wt/WTableView.h:94:16: note:   no known conversion for argument 1 from ‘std::remove_reference<Wt::Dbo::QueryModel<Wt::Dbo::ptr<Utente> >*&>::type {aka Wt::Dbo::QueryModel<Wt::Dbo::ptr<Utente> >*}’ to ‘const std::shared_ptr<Wt::WAbstractItemModel>&’

This is a Utente class: class Utente { public: Utente(); std::string nome; std::string cognome;

    template<class Action>
    void persist(Action& a)
    {
        dbo::field(a, nome, "nome");
        dbo::field(a, cognome,     "cognome");
    }
   ~Utente();
};

this code is in inside in application class :

auto *modelDataTable = new Wt::Dbo::QueryModel<Wt::Dbo::ptr<Utente>>();
modelDataTable->setQuery(session.query<Wt::Dbo::ptr<Utente>>("select utente from utente Utente"));
modelDataTable->addAllFieldsAsColumns();

auto tableView = root()->addWidget(std::make_unique<Wt::WTableView>() );
tableView->setModel( std::move(modelDataTable) );



Aucun commentaire:

Enregistrer un commentaire