Important: Please read the Qt Code of Conduct -

Simplest approach for drawing simple structures (rectangles, lines) in an application?

  • Dear all,

    I am new to Qt and I am a bit confused which class to use for my problem at hand. I want to draw some very simple geometric structures (lines, rectangles) in my window, just like a labyrinth seen from above. Having used the C++ Builder before (previously Borland, now Embarcadero), there my approach was to place a "TImage" in my window, define brush and pen color and then draw onto the TImage's "TCanvas". Is there some similar approach in the Qt API?
    The drawing does not have to be very fast, for the moment simplicity is the main goal. QGraphicsView seems to be overkill for my purpose; first I thought QPicture/QPainter was the way to go, but now I am not so sure about that anymore, since the QPainter approach of recording drawing commands does not quite seem to fit, but maybe I just have to get used to it ...

    Which approach would you recommend?

    Thanks in advance!

  • Moderators

    It all depends, and there are lots of options.

    There is QtQuick, there is QtQuickCanvas (it uses HTML5 canvas API), QGraphicsView and QPainter. All with advantages and disadvantages.

    The easiest to use is probably QtQuick (QML), it also is easy to learn and development usually goes pretty fast in it.

  • Thank you for your answer, I will first give QPainter a try, in case of questions I will return here :-)

    Have a nice weekend.

Log in to reply