Answer the question
In order to leave comments, you need to log in
QAbstractItemModel::beginInsertRows: what happens if the insert fails?
In a descendant of QAbstractItemModel , the insert function may say: insert is not possible for some reason. We do not throw out accidents, we check error codes.
1. How will endInsertRows behave in such a situation?
2. Is it possible to change data classes outside of beginInsertRows/endInsertRows and do nothing between these functions?
3. And if both are not available, what is the best insert architecture to come up with?
Answer the question
In order to leave comments, you need to log in
So far I've come up with this design...
class Committer { // interface
public:
virtual void commit() = 0;
virtual ~Committer() = default;
}
enum class ErrCode { OK, UNCLONEABLE, BAD_RECIPIENT };
struct CommitObj {
ErrCode errCode;
std::unique_ptr<Committer> action;
}
class UiObj {
public:
virtual CommitObj startClone(std::shared_ptr<UiObj> recipient) = 0;
}
What problem are you trying to solve?
beginInsertRows/endInsertRows are needed to notify views about insertion.
It's hard for me to imagine a situation in which you called beginInsertRows but failed to insert data. If there are concerns, you can check the data in advance and only then insert them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question