Results 1 to 6 of 6

Thread: Problem about Graphics View Framework

  1. #1
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem about Graphics View Framework

    Hi, there! I'm trying to develop a graphics editor (similar to MS Paint). For items moving I choose Graphcis View Framework to implement this software. So I have some questions:

    1. How can I implement rubber with Graphics View Framework? Because each item extends QGraphicsItem, may I should override its paintEvent?

    2. If I want to save the scene into a png file, how should I do?

    3. How can I implement function such as eraser?

    I think Graphics View Framework is much suitable for showing sonething not drawing, maybe it is more convenient with QPaint in paintEvent extends QWidget. Any suggestions are welcome!

    Thank you!

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

    Default Re: Problem about Graphics View Framework

    I don't think QGraphicsView is a good architecture to implement a raster based painting application. The thing is you don't have objects there, you operate on the bitmap directly. Of course you can use QGraphicsView but it won't give you that many benefits. Using plain QWidget might be easier for such a simple application. If you want to go beyond Paint and implement features such as layers, etc. then graphics view might be helpful.
    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.


  3. The following user says thank you to wysota for this useful post:

    FinderCheng (31st October 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem about Graphics View Framework

    Yeah, I plan to support layers and some processing like PS. Maybe some day later I will add CImg for editing pictures, so I choose Graphics View Framework. But it is not suitable for drawing, I think.

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

    Default Re: Problem about Graphics View Framework

    Quote Originally Posted by FinderCheng View Post
    But it is not suitable for drawing, I think.
    Not really. At least not more than plain QWidget.
    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.


  6. #5
    Join Date
    Sep 2009
    Location
    Nanjing, China
    Posts
    46
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem about Graphics View Framework

    But I don't know how to do that. Should I override the paint event function? How can I implement rubberband? Override paint and mouseDragEvent or override dragEvent? Thanks!

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

    Default Re: Problem about Graphics View Framework

    Quote Originally Posted by FinderCheng View Post
    Should I override the paint event function?
    Yes.
    How can I implement rubberband?
    See QRubberBand, you have an example there.
    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.


Similar Threads

  1. Model Or View problem
    By Nefastious in forum Newbie
    Replies: 2
    Last Post: 9th October 2009, 20:44
  2. about the contextMenuEvent in graphics view framework
    By bingoking in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2009, 07:04
  3. Graphics View Queries
    By linuxdev in forum Qt Programming
    Replies: 13
    Last Post: 7th January 2009, 10:44
  4. graphics view FitInView problem
    By aamer4yu in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2007, 11:24
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 20:42

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.