I am currently using a QItemDelegate using setModelData(). When I create a new row I create a QList of existing items using findItems(). So it is possible to set the duplicate data for a new row where newLineNumber == oldLineNumber.
I think I will just write a loop which will update the entire model using the same method.
This is my third week using Qt so I wouldn't have a clue how to implement a custom model.
But I am interested in item roles, and custom flags. I already have a script which tests Qt::ItemIsEditable and I would like to add another custom flag to this test.
I have attempted to implement the example in my subclassed QStandardItemModel header file.
{
Q_OBJECT
public:
.....
enum Option {
NoOptions = 0x0,
myFlag1 = 0x1,
myFlag2 = 0x2,
//SqueezeBlank = 0x4
};
Q_DECLARE_FLAGS(Options, Option)
...
};
Q_DECLARE_OPERATORS_FOR_FLAGS(myStandardItemModel::Options)
class myStandardItemModel : public QStandardItemModel
{
Q_OBJECT
public:
.....
enum Option {
NoOptions = 0x0,
myFlag1 = 0x1,
myFlag2 = 0x2,
//SqueezeBlank = 0x4
};
Q_DECLARE_FLAGS(Options, Option)
...
};
Q_DECLARE_OPERATORS_FOR_FLAGS(myStandardItemModel::Options)
To copy to clipboard, switch view to plain text mode
How do I set the flag?
item->setFlags(myStandardItemModel::myFlag2);
item->setFlags(myStandardItemModel::myFlag2);
To copy to clipboard, switch view to plain text mode
Throws a "no matching function call" error.
cheers
C:\dev\standardItemModel\lineeditdelegate.cpp:274: error: no matching function for call to 'QStandardItem::setFlags(myStandardItemModel::Option)'
item->setFlags(myStandardItemModel::myFlag2);
^
C:\dev\standardItemModel\lineeditdelegate.cpp:274: error: no matching function for call to 'QStandardItem::setFlags(myStandardItemModel::Option)'
item->setFlags(myStandardItemModel::myFlag2);
^
To copy to clipboard, switch view to plain text mode
Bookmarks