Weird plot background color issue
Brought to you by:
rathmann
|
From: Murphy, S. <sm...@wa...> - 2019-10-07 17:35:21
|
I'm having a weird issue that I wanted to float by everyone and see if it rings any bells: when we mix changing a plot's background color with changing the plot's parent/child hierarchy, the plot sometimes reverts it's background color to the original color, not the one we think we set it to. Much, much deeper info: 1. I have a plotContainer class, which holds 1-N QwtPlots in vertical alignment. That plotContainer class normally lives within the QMainWindow hierarchy, but the user has the ability to drag that class out of the MainWindow object where it becomes a child of a standalone widget. The user can then reattach the plotContainer to the main window, putting it back within the QMainWindow hierarchy. 2. I also have the ability for the user to open up a color picker dialog to change some of the plot colors (plot background, grid, and cursor). If there are multiple plots shown, selecting a new color on the color picker dialog simultaneously changes the color on all plots. New plots created after a color change are created with the new color scheme, so all the plots should match. These two features work fine on their own, for example, both of these sequences work correctly: Detaching/reattaching plotContainer from/to MainWindow: 1. Start with the plot backgrounds as some initial color, say green 2. Drag the plotContainer out of MainWindow. Color stays green (expected) 3. Click button to reattach to MainWindow. Background remains green (expected) 4. Move mouse over plot. Background remains green (expected) Changing colors: 1. Start with the plot backgrounds as some initial color, say green 2. Use the color picker to change color to blue. Background changes to blue (expected) 3. Move mouse over plot. Background remains blue (expected) So they work fine until I mix them together. For example, this sequence fails: 1. Start with the plot backgrounds green 2. Drag the plotContainer out of MainWindow. Background remains green (expected) 3. While the plotContainer class is popped out, use the color picker to change the background color to blue. Background changes to blue (expected) 4. Click a button to reattach to MainWindow. plotContainer becomes part of the main window hierarchy again. Background remains blue (expected) 5. Move mouse over plot. Background color immediately switches to green (NOT expected, should have remained blue) I've gone through my code and I'm only calling setCanvasBackground() in one spot - when the user uses the color picker to explicitly change the background color. If I set a breakpoint there, the breakpoint will get triggered in step #3 (expected), but the breakpoint is not triggered elsewhere - specifically it is NOT triggered in step #5 when the user mouses over the plot. So I'm completely at a loss for how the plot is changing colors back to the original color. I can't find any places in my code where I'm calling QwtPlotCanvas::setPalette() either. I'm still digging through my code trying to see if I can find any spot where I'm changing it via some other method, but at the moment I can't find a spot where I'm changing it unintentionally, nor can I find a spot where I'm even saving the original color (so in this example, the original green color) to even change it back to once the user has explicitly changed it to something new. Does this sound familiar to anyone? Is there any spot within the QwtPlot code where it would somehow be storing the previous background color that I should be looking at? Sean This message has been scanned for malware by Forcepoint. www.forcepoint.com |