QT Model/View Project doesnt show Strings from QList -
My QTableView does not show strings from a QStringList.
I have QTableWidgetItems in QTableWidget. Should I set strings manually or show them the view automatically? In all tutorials I do not see "- & gt; setItem", they appear automatically.
I have 2 quillin edits that give QStrings to my model:
see zero: pushButtonClicked () {meinModel-> Setdata (txtname-> text (), txtvalue- & gt; text ()); } In the set data I push the string into two questions.
names.push_back (name); Values.push_back (value); I emit a data, indicating with index - from lower and lower.
QModelIndex topLeft = createIndex (names.size () + 1,0); QModelIndex bottomRights = createIndex (names.size () - 1,1); Data throwing changed (top left, right below); I have QAbstractTableModel and therefore I override the column, row, row, and data method. In my data () method I return my value and name:
QString returnValue; If (0 == index.column ()) {returnValue = names.at (index.row ()); } It compiles without all the notation, but does not work properly: (Is there anything that I'm clearly doing wrong?
An obvious problem is that you do not get the correct words of datachanged . dataChanged This means that the existing item has changed its value. When you change the model's structure by adding / removing rows or columns You startX Xx and endXxx call - see details. For example:
zero MyModel :: setData (const QString & name , Const QString and value) {startInsertRows (names), names.size (), names.size ()) names.push_back (name); values.push_back (value); endInsertRows ();} < / Ex>
Comments
Post a Comment