[SOLVED] Best approach to include a graphical scene in a classical GUI



  • Suppose you have a classical GUI with menu's, tree views etc. You want to include a simple statical graphical scene with lines, circles rectangles that you can click on to trigger events. What is the best approach:

    • QPainter on a QFrame, but then how to know on which graphical item the user clicks?
    • Qt Quick, seems overkill and not sure it can be embedded
    • QGraphicsScene, same remark as it needs QGraphicsView to show it
    • Other possibilities?

    Please advise!


  • Qt Champions 2016

    @JanLaloux said:

    I vote for QGraphicsView as would be very fast to implement,
    Please see the 40000 sample.

    You could also just use widgets with your own paint event and a property to
    specify if its a circle / rectangle. Sort of a Shape Widget and then just override mouse events and you know when its clicked. But close lines might cause clicking issues.

    Will it change over time or be like a static image ?



  • @mrjj It will change but in a "static" way: items can be hidden by clicking on it, the result of calculations will be shown by means of encircling items and drawing arrows between them, so no animations or other fancy stuff.
    I will have a look at the 40000 Chips example, thanks.


  • Qt Champions 2016

    @JanLaloux
    Ok, that kind of static.
    Also see the Diagram Scene sample. Its a mini drawing app and it has arrow drawing :)
    The "items" that will be encircled. Those are text or ?



  • @mrjj Correct, it's numbers that are encircled. The Diagram Scene example looks interesting!


  • Qt Champions 2016

    @JanLaloux
    Aha, sounds interesting.
    Yeah, I assumed that it would as it sort
    of sounded a bit like that.
    Should be easy to adjust it for your needs and is not much more code
    than some basic widget drawing would be.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.