In the constructor, you set the column count for your model to 2.
In the code you just posted, you are creating a list that (is supposed to) contain one item for every file in your directory. You then (think you) are appending -one- row for each of those file names. There could 100 of them, almost certainly more than 2.
But that's not what your code is doing. In the code you posted above, you create -one- QStandardItem and use it over and over again for each filename. After you exit the loop, your -one- QStandardItem contains the name of the -last- filename. You then push that onto the list, and that list now contains only -one- item. So you add one row to the table, and it contains only the filename in the first column.
Your code should be doing this:
for each file: (all this code is inside the foreach loop)
{
- create the (empty) list
- set the text for that item to the file name
- push that item onto the list
- retrieve the status for the file
- set that text on the second item
- push the second item onto the list
- append a row to the table using that two item list
}
for each file: (all this code is inside the foreach loop)
{
- create the (empty) list
- create a QStandardItem
- set the text for that item to the file name
- push that item onto the list
- create a second QStandardItem
- retrieve the status for the file
- set that text on the second item
- push the second item onto the list
- append a row to the table using that two item list
}
To copy to clipboard, switch view to plain text mode
And PLEASE use CODE tags when posting code. Your posts are almost completely unreadable without them. See my signature below to learn how to do that.
Bookmarks