DcmStack stack;
DcmObject *dobject = NULL;
DcmElement *delem = NULL;
OFCondition status = dataset.nextObject(stack, OFTrue);
while (status.good())
{
dobject = stack.top();
/* do something useful with the current object, e.g. check
identifier: dobject->ident() */
...
delem = (DcmElement *)dobject;
/* do something useful with the current element, e.g. get
string value: delem->getOFString(string) */
...
status = dataset.nextObject(stack, OFTrue);
}
How do I apply this code on a specific file? Something like loadFile()???
I want to show the tags in a hierarchical structure...
The example you provided doesn't show how to get all tags from a dicom file. It just shows how to get specific tags :S
I really need to show all tags in a dicom file, in a TreeView...
How do I iterate trough all sequences and their child tags? I tried to use nextObject() in combination with getTag(), but it doesn't contain a hierarchy. I am not sure how to devide parents from children tags.
you should be able to use ident() on each element you're iterating over. This returns you the type of object (in form of a DcmEVR enum, all possible values are in dcvr.h). Alternatively, if you just need to know whether the element has a subtree (what you denoted as "parent") or is just a leaf ("child"), you could use isLeaf() instead.
In terms of getting a flat list a la getChilds() or so? No, you have to iterate. Note that the second parameter of nextObect() determines whether a sequence is entered (ie. the child of the sequence will be the next object) or not (then the element after the sequence is next, with all children being skipped).
Thank you for your help so far, but unfortunately I have a big problem. I am using DCMTK as part of my schoolproject, but I have no progress for almost a week, because I cannot figure out how to show all tags in an hierarchical tree view. Could you please help me creating some example code in order to iterate over all tags. You would save my life, since the deadline of my project is at the end of this month . To be clear, I dont need your help creating Qt "viewing" code.
How do I know when a item/sequence ends? How can I get "Item Delimitation Item (fffe),(e00d)" and "Sequence Delimitation Item (fffe),(e00d)" ?
I really need it in order to show it in a treeview.