Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating a table in Qt
    primarykey
    data
    text
    <p>I'm trying to improve <a href="http://www.informit.com/articles/article.aspx?p=1405545&amp;seqNum=4" rel="nofollow">this</a> example for a diagram editor.</p> <p>The example uses a <em>nodes</em> class with a few attributes unrelated to my needs. Right now I want to add a "list of arrays" to this <em>node</em> class in order to then populate a QTableView in the "properties" dialog. I already designed the properties dialog with the QTableView. I'm not even sure this is feasible/makes sense.</p> <p>Basically the table must have 4 columns: <em>name</em>, <em>type</em>, <em>value</em> and <em>unit</em>.</p> <p>Each row of the table is a certain "property" I need the node to have.</p> <p>My question is: <strong>how can/should I model the table at class level?</strong> I ask this because I have been looking to QList, QVariant, QMap, QMultiMap and I can't figure out out to use them correctly, and none of the examples I found so far are any help either, at least for what I need to do. I saw something about the <a href="http://harmattan-dev.nokia.com/docs/library/html/qt4/qstandarditemmodel.html" rel="nofollow">QStandardItemModel</a> class, and I think it relates to the solution, but I can't understand how/why.</p> <p>To top it off, I'm a Qt/C++ beginner, so much of the dynamics and jargon in Qt/C++ are still elluding me.</p> <p>If anyone could give me some pointers, that would be great.</p> <p><strong>EDIT:</strong> This isn't getting much attention, and I don't know if its because I wasn't clear enough, but anyway, try to picture this:</p> <ul> <li>a <em>Node</em> has a <em>PropertyList</em></li> <li>that <em>PropertyList</em> lists <em>Properties</em></li> <li><em>Properties</em> are sort of dictionaries, as they have <strong>always</strong> 4 attributes and respective values: <em>name</em>:(string), <em>type</em>:(string), <em>value</em>:(double) and <em>unit</em>:(string).</li> <li>one <em>Node</em> can only have one <em>PropertyList</em>; a <em>PropertyList</em> can have several <em>Properties</em>. Some <em>Nodes</em> will have 3 <em>properties</em>, others will have 4, etc...</li> </ul> <p>Now, the <em>Nodes</em> are represented in a diagram via a QGraphicsScene with QGraphicsItem. You can access a <em>PropertiesDialog</em> widget that has a <em>QTableWidget</em> in it. This table will show the <em>PropertyList</em>.</p> <p>I want to know what kind of "structure" I can create/define that enables me to easily insert/read data in the table widget - ie, I load the data into the <em>PropertiesList</em> of the <em>Node</em> and it shows up in the table widget; if I change the data in the table widget, it passes on to the <em>PropertiesList</em> of the <em>Node</em>.</p> <p>Hope this helps clearing out any doubts that may arise.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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