0

I'm currently trying to draw the top view of a boat by using Qt 4.8 (C++). I want to implement a QWidget in which a boat moves around.

Therefore I need to draw the top view of a boat, it should look similiar to this (only need the outer boarders):

example of boat
(source: 4vector.com)

Currently I'm experimenting with QPainter in combination with QPainterPath but I can't figure out how to combine the ellipsoids and rectangles correctly. Another option would be to draw it as an polygon but I would need a lot of points to let it look good.

Besides I think a solution by using only a rectangle and two ellipsoids or simliar solutions would be more beautiful.

Many thanks in advance for your help!

Community
  • 1
  • 1
  • Why do you need to draw it with QPainter instead of drawing/loading a pixmap and move it around? – vahancho Jul 20 '15 at 14:45
  • I would prefer using the QPainter tool to reach more flexibility. – Philipp Doublehammer Jul 20 '15 at 14:51
  • Flexibility? In which sense? You might simply load an image posted above in your question and use it as your painting instead of drawing complex curves. – vahancho Jul 20 '15 at 14:55
  • Flexibility in the sense of that I am able to transform the boats shape, fill and color at runtime. – Philipp Doublehammer Jul 20 '15 at 14:58
  • 1
    I would go with @vahancho input If you are talking about a finite number of shapes. Still if you want to go with QPainter use `QPainterPath::cubicTo` and subtract from rectangles using `QPainterPath::subtracted` – techneaz Jul 20 '15 at 15:33
  • @vahancho Using a pixmap is always a bit problematic for geometric shapes (zooming, rotation, scaling, overlapping other shapes...), because pixmap consists of pixels. – hyde Sep 29 '19 at 11:29
  • Philipp, what exactly is the problem you ate having with your painter code? It's hard to tell how to fix the code when you don't show the code. – hyde Sep 29 '19 at 11:31
  • I would start with boat made of 5 straight lines. Then once that works, change the two nose lines to be Bezier curves (read the doc!). – hyde Sep 29 '19 at 11:34

0 Answers0