Hi,
I am quite new tho Model/View approach and I need your help. I am reading a text file and want to display data in a tableview. I already looked at example codes but they are very basic and my requirements are very different.
Text from file looks like:
Page Address Name
....
1 0000abda _CpuTimer1
1 0000abe2 _CpuTimer2
1 0000abea _CpuTimer0
1 0000abf2 _msg
1 0000abf4 _res
....
Page Address Name
....
1 0000abda _CpuTimer1
1 0000abe2 _CpuTimer2
1 0000abea _CpuTimer0
1 0000abf2 _msg
1 0000abf4 _res
....
To copy to clipboard, switch view to plain text mode
I store those information to a QVector of following typedef:
typedef struct St_Register
{
quint16 page;
quint16 address;
quint32 currValue;
quint32 wrValue;
bool wrProtect;
} Register;
...
QVector<Register *> Registers;
typedef struct St_Register
{
QString name;
quint16 page;
quint16 address;
quint32 currValue;
quint32 wrValue;
bool wrProtect;
} Register;
...
QVector<Register *> Registers;
To copy to clipboard, switch view to plain text mode
But as soon as I store the data into Registers vector, It should update the table automatically.
I want to show Name, Page, Address, currValue information in the table as not editable strings. I want to show wrProtect as editable checkbox and wrValue as editable spinbox.
When I check the checkbox, the wrValue should be editable, otherwise not editable.
So, Is my data-model only this QVector? QVector<Register *> Registers;
Do I need customized checkbox delegate and spinbox delegate? If yes, how? How can I "connect" those specialized delegates to tableView (or to model)?
I need a step-by-step instruction for implementing of creating all required classes (pseude-code is enough).
Thanks.
Bookmarks