Reputation: 301
I have an implementation question. Before I start, I'm using Qt4 Creator with OpenGL.
So I have this node class, defined like this
class node {
private:
std::vector <node*> leaves;
node *parent;
gMatrix3 t;
polygon *p;
public:
node()
void addLeaf(node *n);
void remove();
// and other
}
I have a class scene defined like this ~
private:
node* root;
public:
scene();
node* getRoot();
};
The constructor of scene creates a tree of node objects, each of which stores a transformation matrix, a pointer to a polygon, a pointer to its parent node, and a vector of pointers to its children.
Finally, I have a draw function which recursively traverses the tree and calls OpenGL to draw the scene.
So now, I want to build a GUI that gives the user the ability to explicitly add nodes to the graph as a child of any other node, and to remove any leaf node in the structure. I'm vaguely familiar with Qt's TreeWidget class, but I have never used this before and the tutorials on the website are difficult to follow.
Could someone point to in the right direction / suggest any reading material that could get me started?
Upvotes: 1
Views: 995
Reputation: 9455
Check out this project, where tree widget has been used extensively.
https://github.com/adnan-kamili/ShareScanner/blob/master/sharescanner.cpp
And this article should act as your base: http://qt-project.org/doc/qt-4.8/model-view-programming.html
Upvotes: 1