How to store restore the colors in QGRaphicsView



  • Hi All
    I have a QGraphicsView in which I have rectangles .

    1. I have two modes for this QGraphicsView

    View1 - in which I color the rectangles and I can edit the color of these rectangles. The rectangles colors can be dynamic

    View2 _ where I always have no colors of rectangles

    I have following flow

    View1 - > in which I will change the colors of the rectangles

    View2 - in which I will clear the color

    View1- I go back to View1 .

    My Requirement is to restore the View1 (with edited colors) before we got into view2

    Is there any way to save and restore the colors for View . Also can I use QSetting for this ?


  • Lifetime Qt Champion

    Hi,

    So basically your view number 2 is a black and white view over a scene while view 1 shows the original coloured content of said scene, correct ?



  • @SGaist

    Yes Basically I have following States

    State1 -- IN View 1 I have colors of rectangles it can be red/ gree etc FOr example Rect1 is yellow

    State2 - In View 1 I changed the colors of rectangles for Rect1 to Red

    State 3 : Go to View 2 , there are not colors mean black and white View

    Satet4 , Go back to View2 and Now I want to go back to State2 , where I have Rect1 as red

    Also
    Another use case

    State1 -- IN View 1 I have colors of rectangles it can be red/ gree etc FOr example Rect1 is yellow

    State2 - In View 1 I changed the colors of rectangles for Rect1 to Red

    State3 : exit the tool

    State 4 . start the tool and now I want to go back to state 2 Rect should be Red

    Please suggest some optimied solution

    I



  • @SGaist Any suggestions you have ?


  • Qt Champions 2016

    @Qt-Enthusiast
    If you only have 2 states, why not just have a second color for your items and when
    in mode2, it uses that color to paint and if in mode 1 , use the original color.

    Do you need to save to file, the colors ?

    If yes, you could also just use the save/load (that you need any way) and simply load the color when back to view 1.


Log in to reply
 

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