How to can i stop from painting the background widget in paintevent?
-
Hello,
I am using Qt 5.12.3, and visual studio 2017.
I am plotting the graph in real time in my application. I repainting the canvas of graph whenever the data point is arrived.
On paint event the canvas is repaint with background widget also.
How to can I stop from painting the background widget in paintevent?
I would like to just add the data point on plot.
I can set the cliping area at particular location. but if any other widget is available in backside of clipping rect then it is showing?
On paint event i am getting plot like below pic.
I would like something like below pic even another Qwidget is still on background.
Any suggestion?
-
@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 ? -
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 ? -
@mrjj
If I understand correctly then yes.In general I do have graph like below pic whenever data is not arrived.
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); -
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 ?
-
@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 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.
-
@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. -
@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 windowPlus1102[ch 1] expA ....
.
Now expA is stop and click on restore down button, and place window
Plus1102[ch 1] expA
on right side.now start expB and At that time another window is created. The title of window
Plus1102[ch 1] expB ....
.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 ....```. -
@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. -
@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 ?