Results 1 to 17 of 17

Thread: How to Draw a tree by using QT?

  1. #1
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default How to Draw a tree by using QT?

    Hello
    I want to build a tree.
    Such that the image
    Diagram2.png

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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw a tree by using QT?

    You have two options:
    "regular" draw with QPainter on a widget.
    Or , what I think would probably suit you better - use QGraphicsView.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    Quote Originally Posted by high_flyer View Post
    You have two options:
    "regular" draw with QPainter on a widget.
    Or , what I think would probably suit you better - use QGraphicsView.

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

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw a tree by using QT?

    That is dependent on YOUR implementation!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    Quote Originally Posted by high_flyer View Post
    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...

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw a tree by using QT?

    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/graphic...sticnodes.html

    You just don't need the "elastic" part.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    Quote Originally Posted by high_flyer View Post
    this example however might be close to what you need:
    http://doc.trolltech.com/4.7/graphic...sticnodes.html
    Thank you
    I have loaded the program
    But did not come out the Edge.
    How do I link nodes?

  8. #8
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    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. There is an attachment in the last post with the code.

    Best regards,
    Marc

  9. #9
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    Quote Originally Posted by marcvanriet View Post
    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. 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 ?

  10. #10
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    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.
    Attached Files Attached Files
    Last edited by marcvanriet; 14th November 2010 at 22:43. Reason: updated contents

  11. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How to Draw a tree by using QT?

    Quote Originally Posted by NewLegend View Post
    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.

  12. #12
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    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

  13. #13
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    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.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Draw a tree by using QT?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to Draw a tree by using QT?

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  16. #16
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: How to Draw a tree by using QT?

    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.

  17. #17
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to Draw a tree by using QT?

    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

Similar Threads

  1. SQL Tree Model Help
    By MTK358 in forum Newbie
    Replies: 9
    Last Post: 22nd June 2015, 15:02
  2. About tree organization...
    By Patrick Sorcery in forum Newbie
    Replies: 2
    Last Post: 3rd September 2010, 07:43
  3. Tree without using of QStandardItem
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2010, 12:23
  4. Tree structure
    By ikm in forum Newbie
    Replies: 1
    Last Post: 7th August 2009, 20:19
  5. What if QT tree is moved?
    By QPlace in forum Installation and Deployment
    Replies: 2
    Last Post: 3rd November 2008, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.