Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Normally I would implement my own model inheriting from <code>QAbstractItemModel</code> directly and provide my own implementation for the presentation functions such as <code>data()</code> to handle the data storage container I give the model.</p> <p>If you have code duplication for using <code>QList&lt;T&gt;</code> and <code>std::vector&lt;T&gt;</code> then I would suggest converting one to the other by doing either:</p> <pre><code>QList&lt;T&gt; list = QList::fromVector(QVector::fromStdVector(vector)); </code></pre> <p>or the other way.</p> <pre><code>std::vector&lt;T&gt; vector = qlist.toVector().toStdVector(); </code></pre> <p>I'd do the latter but you can choose either.</p> <p>Based on your additional comments there are 2 paths of action you can take:</p> <p>Path 1:</p> <p>Implement <code>objectA</code> and <code>objectB</code> as follows: </p> <pre><code>class objectA : baseObject </code></pre> <p>and </p> <pre><code>class objectB : baseObject </code></pre> <p>where <code>baseObject</code> is: </p> <pre><code>struct baseObject { virtual std::string toString() = 0; }; </code></pre> <p>Probably easier to convert to string then anything else.</p> <p>Path 2 will basically involve inside the model using <code>std::vector&lt;boost::any&gt;()</code> as your data storage container, this way you can implement a single model subclassing <code>QAbstractListModel</code>.</p> <p>The thing that you have to consider that if your data storage container you can probably make common the data presentation you are limited at what you can do because <code>data()</code> function that will give your view the element has to return <code>QVariant</code> and it's limited at what you can construct it from.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload