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!
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.
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.
Re: Problem about Graphics View Framework
Quote:
Originally Posted by
FinderCheng
But it is not suitable for drawing, I think.
Not really. At least not more than plain QWidget.
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!
Re: Problem about Graphics View Framework
Quote:
Originally Posted by
FinderCheng
Should I override the paint event function?
Yes.
Quote:
How can I implement rubberband?
See QRubberBand, you have an example there.