PDA

View Full Version : How to Draw a tree by using QT?



NewLegend
12th November 2010, 11:07
Hello
I want to build a tree.
Such that the image
5451

Is there an example or a way ?
Thanks to all.

high_flyer
12th November 2010, 11:13
You have two options:
"regular" draw with QPainter on a widget.
Or , what I think would probably suit you better - use QGraphicsView (http://doc.trolltech.com/4.7/graphicsview.html).

NewLegend
12th November 2010, 11:21
You have two options:
"regular" draw with QPainter on a widget.
Or , what I think would probably suit you better - use QGraphicsView (http://doc.trolltech.com/4.7/graphicsview.html).


Is it static??
Is the user can be created a new Node in the desired location?

high_flyer
12th November 2010, 12:40
That is dependent on YOUR implementation!

NewLegend
12th November 2010, 13:20
That is dependent on YOUR implementation!

I read the file QGraphicsView.
But I think it is very complex.
Do you have a simple example for the construction of this tree, Or at least 2 nodes.
Thank you very much...

high_flyer
12th November 2010, 13:40
Have a look at the examples delivered with your Qt installation.
this example however might be close to what you need:
http://doc.trolltech.com/4.7/graphicsview-elasticnodes.html

You just don't need the "elastic" part.

NewLegend
13th November 2010, 15:59
this example however might be close to what you need:
http://doc.trolltech.com/4.7/graphicsview-elasticnodes.html


Thank you
I have loaded the program
But did not come out the Edge.
How do I link nodes?

marcvanriet
14th November 2010, 00:50
Hi,

I started a little project to do just that some time ago. Haven't finished it yet, but it may be helpfull.

Just see the thread : Mindmapping widget (http://www.qtcentre.org/threads/35243-Mindmapping-widget). There is an attachment in the last post with the code.

Best regards,
Marc

NewLegend
14th November 2010, 07:31
Hi,

I started a little project to do just that some time ago. Haven't finished it yet, but it may be helpfull.

Just see the thread : Mindmapping widget (http://www.qtcentre.org/threads/35243-Mindmapping-widget). There is an attachment in the last post with the code.

Best regards,
Marc

Thanks for this link.
But the file attachment in the thread does not work.
Can you upload the file again ?

marcvanriet
14th November 2010, 22:39
Hi NewLegend,
Works perfectly for me. Downloaded and build without problems. Will try and send it in a private message.
Regards,
Marc

Edit : seems youj can't attach anything to a private message. You'll find it attached to this reply.

tbscope
15th November 2010, 07:06
I read the file QGraphicsView.
But I think it is very complex.

You want to build a rocket to go to the moon, but you don't want to spend more than 5 minutes on it or it will become too complex?

Accept that there isn't a solution for everything. Most of the time, you need to create something yourself.

You writing that reading a document to find out something is complex and you wanting to get everything ready made for free leads me to think you don't want to do this but need to do this.
If you need to do this, this is either homework or real work.

If you want to do this, you still might think it is complex (nothing wrong with that) but you'll ask questions to understand the things you find complex.
If you need to do this, you might think it is complex, but you will not ask questions to understand why things work the way they do, you'll just ask others to do the work for you.

It's commendable that some people actually want to help you. Me, however, have had multiple bad experiences helping people who don't know anything or do not show any will to learn anything.

marcvanriet
15th November 2010, 12:12
Hi tbscope,

I agree with your comment. When reading many posts I think by myself the poster really hasn't got any notion of programming.

I myself have 20 years of programming experience in C / C++ / Pascal / Basic(s) / Python / Visual Foxpro / Delphi / assembler / ... Picked up Qt since about a year now as an alternative to Borland Delphi / C++ Builder.

But even with this experience, I find that it is sometimes difficult to learn something completely new from the samples because the samples show too many things at once. If you want to start using a QGraphicsview, the samples show lots and lots more than just creating a QGraphicsview and putting some objects in it. Also learning something completely new from the help files is not easy because they show all the details, instead of just the big perspective that you need at first. A few "examples for dummies" would be helpfull, that only show 1 or 2 features at a time.

I would advise everyone who starts using Qt to find yourself a good book. It gets you started creating your first programs and introduces the basic concepts. After that, you can find out more of the fancy stuff in the help or in the examples.

And of course... you MUST first know C/C++. If you don't, find a book on C/C++ first.

Best regards,
Marc

NewLegend
15th November 2010, 13:15
Have you read the maxim ''don't reinvent the wheel' ?
Do you want me to read books and folders to Make a set of Nodes?

I here to take advantage from the experiences of qt users such as, marcvanriet.

wysota
15th November 2010, 13:20
Do you want to have a logical tree or do you want to draw a tree that you already have? This thread goes into the direction of drawing a tree but the text in the post is not clear about it.

high_flyer
15th November 2010, 13:27
Have you read the maxim ''don't reinvent the wheel' ?
No one wants you to reinvent the wheel, just to understand how it work, if you want to use it.
If you don't know how something works, you wont be able to use it.
The only way to know how something works, is, to learn how it works, and that is usually done either by reading, or by being taught by someone else.
The wheel is invented and ready to be used, if you want to use it, you will have to read about how it works.
I find Qt example code in the docs very good and it helps me always when I learn something new in Qt.
You have been give a path to a solution to your problem, but it seems you lack the drive to invest the time and apcience it take to understand it.
With that, no one help you, not even marcvanriet experience.
Try reading and understanding, and when you have SPECIFIC questions about things you don't understand you are more than welcome to ask here.
But saying "its too complected for me to read - give me something simple, ready to use that I don't have to think about" will not get you far.

chris_helloworld
16th November 2010, 08:06
Another good book for a C++ developer getting into Qt for the first time is
C++ GUI Programming with Qt3 by Jasmin Blanchette and Mark Summerfield.

Theres a Qt4 version of this book too I believe. (I think the version 3 book can be found freely available to download online too).

It does exactly what Marc says you need - ie, gives an entry point for experienced programmers to quickly get to grips with the basics of Qt before they delve into the details. Of course, if you dont like books theres always the source code to read :)

Chris.

d_stranz
26th November 2010, 19:29
The new book by Mark Summerfield (Advanced Qt Programming) is also excellent. It has extensive coverage of some of the newer Qt features, such as Phonon, Model / View, and Graphics / View frameworks. I haven't found anything else like it