Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to store restore the colors in QGRaphicsView
Qt 6.11 is out! See what's new in the release blog

How to store restore the colors in QGRaphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 2 Replies Last reply
      1
      • SGaistS SGaist

        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 ?

        Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by Qt Enthusiast
        #3

        @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

        1 Reply Last reply
        0
        • SGaistS SGaist

          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 ?

          Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          @SGaist Any suggestions you have ?

          mrjjM 1 Reply Last reply
          0
          • Q Qt Enthusiast

            @SGaist Any suggestions you have ?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved