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 can i stop from painting the background widget in paintevent?

How to can i stop from painting the background widget in paintevent?

Scheduled Pinned Locked Moved Solved General and Desktop
qpaintqpaintergraphc++qwt
11 Posts 2 Posters 3.5k Views
  • 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 16 Dec 2019, 18:28 last edited by
    #2

    Hi
    You mean to make the front widget completely transparent so it draws its data point as overlay on the widget under it or what do you mean ?

    Y 1 Reply Last reply 16 Dec 2019, 18:33
    0
    • M mrjj
      16 Dec 2019, 18:28

      Hi
      You mean to make the front widget completely transparent so it draws its data point as overlay on the widget under it or what do you mean ?

      Y Offline
      Y Offline
      Yash001
      wrote on 16 Dec 2019, 18:33 last edited by Yash001
      #3

      @mrjj
      If I understand correctly then yes.

      In general I do have graph like below pic whenever data is not arrived.

      30d89473-029b-40ec-9269-8e87d3921c04-image.png

      Curve (blue line in my first pic) will plot on graph whenever the live data is arrived. I am using paint event to make visible data point on graph.

      This are the flag set in canvas on graph.
      setAttribute(Qt::WA_PaintOnScreen, true);
      setAttribute(Qt::WA_NoSystemBackground, true);

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 16 Dec 2019, 18:41 last edited by mrjj
        #4

        Hi
        But why you want to have 2 widgets then ?
        Could you not just draw 2 graphs on the first widget ?

        it looks like when you get data, you create yet another QWT widget ?

        Y 1 Reply Last reply 16 Dec 2019, 18:58
        0
        • M mrjj
          16 Dec 2019, 18:41

          Hi
          But why you want to have 2 widgets then ?
          Could you not just draw 2 graphs on the first widget ?

          it looks like when you get data, you create yet another QWT widget ?

          Y Offline
          Y Offline
          Yash001
          wrote on 16 Dec 2019, 18:58 last edited by Yash001
          #5

          @mrjj said in How to can i stop from painting the background widget in paintevent?:

          it looks like when you get data, you create yet another QWT widget ?

          Yes, I do have different exp. every time QWT widget create while starting of new experiment.

          lets say I have exp A and exp B.

          if user will start expA then subwindowA will create with button and Qwtplot.
          if user will start expB then subwindowB will create with button and Qwtplot.

          Now if live data arrived and if data point is for expA then it is visible in Qwtplot of subwindowA .
          if data point is for expB then it is visible in Qwtplot of subwindowB .

          Now if I will click on restore down button 3fd8b7be-a85f-4803-b061-e4017c51be03-image.png of subwindowA and put in back side of canvas of Qwtplot in subwindowB. ( currently subwindowB is in Maximized stat)

          then subwindowA widget is showing in canvas of Qwtplot in subwindowB while data point of arrive of expB.

          M 1 Reply Last reply 16 Dec 2019, 19:21
          0
          • Y Yash001
            16 Dec 2019, 18:58

            @mrjj said in How to can i stop from painting the background widget in paintevent?:

            it looks like when you get data, you create yet another QWT widget ?

            Yes, I do have different exp. every time QWT widget create while starting of new experiment.

            lets say I have exp A and exp B.

            if user will start expA then subwindowA will create with button and Qwtplot.
            if user will start expB then subwindowB will create with button and Qwtplot.

            Now if live data arrived and if data point is for expA then it is visible in Qwtplot of subwindowA .
            if data point is for expB then it is visible in Qwtplot of subwindowB .

            Now if I will click on restore down button 3fd8b7be-a85f-4803-b061-e4017c51be03-image.png of subwindowA and put in back side of canvas of Qwtplot in subwindowB. ( currently subwindowB is in Maximized stat)

            then subwindowA widget is showing in canvas of Qwtplot in subwindowB while data point of arrive of expB.

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 16 Dec 2019, 19:21 last edited by mrjj
            #6

            @Yash001
            Ok so you do want 2 widgets.
            But one thing i wonder if you zoom the A one, then when you draw the B one as overlay it would be in wrong positions. But you dont plan to zoom ?

            In any case, im not sure you can tell QWT to not draw the background grid.
            You can remove all borders etc but I think to might need to subclass the QWT class and fiddle with
            its paintEvent function to get it to not draw the grid etc.

            Maybe its enough to make a custom
            https://qwt.sourceforge.io/class_qwt_plot_grid.html#details
            and have it draw noting.

            Y 1 Reply Last reply 16 Dec 2019, 19:56
            0
            • M mrjj
              16 Dec 2019, 19:21

              @Yash001
              Ok so you do want 2 widgets.
              But one thing i wonder if you zoom the A one, then when you draw the B one as overlay it would be in wrong positions. But you dont plan to zoom ?

              In any case, im not sure you can tell QWT to not draw the background grid.
              You can remove all borders etc but I think to might need to subclass the QWT class and fiddle with
              its paintEvent function to get it to not draw the grid etc.

              Maybe its enough to make a custom
              https://qwt.sourceforge.io/class_qwt_plot_grid.html#details
              and have it draw noting.

              Y Offline
              Y Offline
              Yash001
              wrote on 16 Dec 2019, 19:56 last edited by
              #7

              @mrjj said in How to can i stop from painting the background widget in paintevent?:

              But one thing i wonder if you zoom the A one, then when you draw the B one as overlay it would be in wrong positions. But you don't plan to zoom ?

              User will interact one Qwtplot widget at time. it is already handle in my code. it work perfectly.

              In any case, im not sure you can tell QWT to not draw the background grid.
              You can remove all borders etc but I think to might need to subclass the QWT class and fiddle with
              its paintEvent function to get it to not draw the grid etc.

              I don't want to hide the grid.
              I think we are not on same page. Let me give you more detail with pic.

              Here the user start expA.
              At that time window is created. The title of window Plus1102[ch 1] expA .....
              b17c6f1f-9f45-4564-9ea9-b9c552229515-image.png

              Now expA is stop and click on restore down button, and place window Plus1102[ch 1] expA on right side.

              88ddc12d-e02a-44e9-a818-c39c126730f5-image.png

              now start expB and At that time another window is created. The title of window Plus1102[ch 1] expB .....

              b1ece283-fcc7-4bfd-836b-f4685da27aaf-image.png

              Now you can see Plus1102[ch 1] expA is showing in canvas of ``Plus1102[ch 1] expB ....```.

              I want to completely hide the window Plus1102[ch 1] expA from canvas of ``Plus1102[ch 1] expB ....```.

              M 1 Reply Last reply 16 Dec 2019, 20:02
              0
              • Y Yash001
                16 Dec 2019, 19:56

                @mrjj said in How to can i stop from painting the background widget in paintevent?:

                But one thing i wonder if you zoom the A one, then when you draw the B one as overlay it would be in wrong positions. But you don't plan to zoom ?

                User will interact one Qwtplot widget at time. it is already handle in my code. it work perfectly.

                In any case, im not sure you can tell QWT to not draw the background grid.
                You can remove all borders etc but I think to might need to subclass the QWT class and fiddle with
                its paintEvent function to get it to not draw the grid etc.

                I don't want to hide the grid.
                I think we are not on same page. Let me give you more detail with pic.

                Here the user start expA.
                At that time window is created. The title of window Plus1102[ch 1] expA .....
                b17c6f1f-9f45-4564-9ea9-b9c552229515-image.png

                Now expA is stop and click on restore down button, and place window Plus1102[ch 1] expA on right side.

                88ddc12d-e02a-44e9-a818-c39c126730f5-image.png

                now start expB and At that time another window is created. The title of window Plus1102[ch 1] expB .....

                b1ece283-fcc7-4bfd-836b-f4685da27aaf-image.png

                Now you can see Plus1102[ch 1] expA is showing in canvas of ``Plus1102[ch 1] expB ....```.

                I want to completely hide the window Plus1102[ch 1] expA from canvas of ``Plus1102[ch 1] expB ....```.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 16 Dec 2019, 20:02 last edited by
                #8

                @Yash001
                Ok, I think i understand now but
                then i get confused why you simply dont call hide() on the window you want to hide?

                Y 1 Reply Last reply 16 Dec 2019, 20:22
                0
                • M mrjj
                  16 Dec 2019, 20:02

                  @Yash001
                  Ok, I think i understand now but
                  then i get confused why you simply dont call hide() on the window you want to hide?

                  Y Offline
                  Y Offline
                  Yash001
                  wrote on 16 Dec 2019, 20:22 last edited by
                  #9

                  @mrjj
                  I try that thing. But It is make slow speed in creation of window as per number of windows is increasing, Because I need to iterate all the windows for hide.

                  Sometime many experiment run at time, and received events in background.
                  There are few other requirements also so that I am not hiding window.

                  M 1 Reply Last reply 16 Dec 2019, 20:33
                  0
                  • Y Yash001
                    16 Dec 2019, 20:22

                    @mrjj
                    I try that thing. But It is make slow speed in creation of window as per number of windows is increasing, Because I need to iterate all the windows for hide.

                    Sometime many experiment run at time, and received events in background.
                    There are few other requirements also so that I am not hiding window.

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 16 Dec 2019, 20:33 last edited by
                    #10

                    @Yash001
                    Well you could just keep a map of open windows, so you dont have to loop all windows but
                    if i understand you correctly, it gets heavy as the other open windows are still active ?

                    You could an install event filer on them to eat all event they get, ( include paintEvent) but
                    is it not so nice as it will look odd if you dont hide it.

                    You could try to use QWidget::stackUnder()
                    to hide it under the other one but it would still be active.

                    So not sure
                    if you dont want to hide it
                    and it should still be active to get events etc.
                    what you want it to do ?
                    simply paint nothing if told so but still be a window and do what else it does ?

                    Y 1 Reply Last reply 27 Dec 2019, 18:33
                    1
                    • M mrjj
                      16 Dec 2019, 20:33

                      @Yash001
                      Well you could just keep a map of open windows, so you dont have to loop all windows but
                      if i understand you correctly, it gets heavy as the other open windows are still active ?

                      You could an install event filer on them to eat all event they get, ( include paintEvent) but
                      is it not so nice as it will look odd if you dont hide it.

                      You could try to use QWidget::stackUnder()
                      to hide it under the other one but it would still be active.

                      So not sure
                      if you dont want to hide it
                      and it should still be active to get events etc.
                      what you want it to do ?
                      simply paint nothing if told so but still be a window and do what else it does ?

                      Y Offline
                      Y Offline
                      Yash001
                      wrote on 27 Dec 2019, 18:33 last edited by
                      #11

                      @mrjj
                      Thank you sir for helping me and direction. I am able to solve this issue by

                      1. setting the clipping area properly on graph.
                      2. Use QWidget::update() instead of QWidget::repaint().
                      1 Reply Last reply
                      1

                      • Login

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