WStandardItem::appendRow gives
Added by Maurice Verreck over 1 year ago
I humbly admit, that this is likely more a programming skills issue, then anything related to Wt. Any advice would still be very much appreciated.
I want to create a simple tree table , so with extra columns, based on a WStandardItemModel. MWE below
//ChapterTree.cpp
#include "ChapterTree.h"
#include "Wt/WStandardItem.h"
#include <vector>
#include <memory>
using namespace Wt;
ChapterTree::ChapterTree() : WContainerWidget()
{
auto p_item0{ std::make_unique<WStandardItem>("parent_col0") };
auto c_item{ std::make_unique<WStandardItem>() };
std::vector<std::unique_ptr<WStandardItem>> c_items;
auto c_item0{ std::make_unique<WStandardItem>("child_col0") };
c_items.emplace_back(std::move(c_item0));
auto c_item1{ std::make_unique<WStandardItem>("child_col1") };
c_items.emplace_back(std::move(c_item1));
c_item->appendRow(c_items); // compilation error
p_item0->setChild(p_item0->rowCount(),0,std::move(c_item));
}
//ChapterTree.h
#include "Wt/WContainerWidget.h"
class ChapterTree: public Wt::WContainerWidget
{
public:
ChapterTree();
~ChapterTree() = default;
ChapterTree(const ChapterTree&) = default;
ChapterTree(ChapterTree&&) = default;
ChapterTree& operator = (const ChapterTree&) = default;
ChapterTree& operator = (ChapterTree&&) = default;
};
The line with appendRow() yields '/usr/include/c++/11/bits/stl_uninitialized.h|138|error: static assertion failed: result type must be constructible from value type of input range' at compilation.
There seems to be a type deduction issue, possibly pimpl-idiom related. If I move the contents of the constructor to the h file, it compiles! I tried various destructor, copy/move constructor implementations, but to no effect.
Replies (1)
RE: WStandardItem::appendRow gives static assertion failure: solved - Added by Maurice Verreck over 1 year ago
Sorry, posted too soon
c_item->appendRow(std::move(c_items));
did the job.