PDA

View Full Version : qwt canvas border



stefan
7th March 2011, 15:23
Hi,
i'm trying to remove sunken canvas (it looks ugly).

ui->qwtPlot->canvas()->setFrameStyle(QFrame::StyledPanel|QFrame::Plain);
but the result is a transparent border line around canvas (transparent - probably because my "transparent oxygen" widget style):
6046
How to remove this border, and get a elegant round border (as in line edit or table widget)?

i tried

ui->qwtPlot->layout()->setMargin(0);
but program crashes on starting ("The program has unexpectedly finished.")

Thanks for any help

Uwe
7th March 2011, 16:10
but the result is a transparent border line around canvas (transparent - probably because my "transparent oxygen" widget style):

Well your screenshot looks like your border is not painted at all. What version of Qwt are you using ?

Recently I was playing around with style sheets and had to learn, that the whole concept is made for Qt widgets only. Nevertheless people want to use style sheets and I hacked a lot of code dealing with rounded borders for the plot canvas.

The problem with rounded borders is, that widgets are designed to be rectangular and the content of a widget needs to be clipped against the rounded borders. Unfortunately the style sheets have no answer to this problem - here you simply add some pixels as padding, what of course is not acceptable for a plot canvas. Further more the style sheet style draws the border as a part of the background, with the effect, that the border gets antialiased against the background - not the plot items ( think about plot items with filled areas like a spectrogram ). So I had to hack the order how background and border are painted.

I'm afraid you will have the similar problems with styles that draw rounded borders. Guess the oxygen style also can't solve the design problem of the QStyle API and also has to add padding.

At the moment QwtPlotCanvas does some reverse engineering of the border for styled backgrounds ( Qt::WA_StyledBackground ) only. I could try to do the same for styled frames - but calculating the clipping, when you don't have an API for the radii of the borders is no fun.

Please try Qwt 6 from SVN trunk ( no snapshot ) with the Oxygen style. You could also try QwtPlotCanvas::setBorderRadius() or if you want to use stylesheets you can try ( and adopt ) choco.css from the examples/stylesheets directory.

Uwe