Re: Draw custom focus indicator
Brought to you by:
rathmann
From: Gerard V. <ger...@gr...> - 2004-07-20 13:35:33
|
On Tue, 20 Jul 2004 14:34:13 +0200 Harald Ueland <ue...@st...> wrote: > Hi, > > I'm working with a project where I display several QwtPlots in a window. > I want to draw a focus indicator on the plot which is selected by the > user (e.g. a red rectangle). > > I have tried to override the drawCanvas function in QwtPlot. This works. > The red rectangle is drawn when the mouse is pressed. But when another > plot is selected, I want to move the rectangle to the new selected plot. > So I have a boolean variable telling me if the plot is selected or not, > and if it is not, the drawCanvas function simply calls the drawCanvas > function in the superclass (QwtPlot). This doesn't work when caching is > enabled in the plot's canvas. Right? I called > self.canvas().setCache(False) (I'm using Python and PyQwt...). Then it > worked. But do I really have to disable caching in order to be able to > remove already drawn shapes on the canvas? > > > Thanks, Yes, drawCanvas() is not "focus aware" and if you simulate a focus indicator by a red rectangle it won't go away on a focus change. It is better to try to subclass QwtPlotCanvas to override the drawFocus method and use this new class in the QwtPlot class (by assigning it to the result of QwtPlot::canvas()). This must work in C++, but I cannot garantee that it will work in Python (probably, but I did not try it). If it does not work, send a little program, please and I will try to modify your program or PyQwt so that it will work. You can also educate your users (or yourself) that focus in a canvas is indicated by a 'civilized' dashed rectangle. Gerard |